{"id":21408686,"url":"https://github.com/raku-community-modules/benchy","last_synced_at":"2025-03-16T17:29:33.857Z","repository":{"id":137930497,"uuid":"91959669","full_name":"raku-community-modules/Benchy","owner":"raku-community-modules","description":"Benchmark some code","archived":false,"fork":false,"pushed_at":"2022-05-19T18:10:48.000Z","size":18,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-23T04:26:07.499Z","etag":null,"topics":["bench","benchmark","raku"],"latest_commit_sha":null,"homepage":"https://raku.land/zef:raku-community-modules/Benchy","language":"Raku","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"artistic-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raku-community-modules.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-21T13:35:28.000Z","updated_at":"2024-11-30T16:29:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"2d18cab6-4208-431d-9810-c931021f4cdd","html_url":"https://github.com/raku-community-modules/Benchy","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raku-community-modules%2FBenchy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raku-community-modules%2FBenchy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raku-community-modules%2FBenchy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raku-community-modules%2FBenchy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raku-community-modules","download_url":"https://codeload.github.com/raku-community-modules/Benchy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243905473,"owners_count":20366830,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bench","benchmark","raku"],"created_at":"2024-11-22T17:17:54.127Z","updated_at":"2025-03-16T17:29:33.852Z","avatar_url":"https://github.com/raku-community-modules.png","language":"Raku","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Actions Status](https://github.com/raku-community-modules/Benchy/actions/workflows/test.yml/badge.svg)](https://github.com/raku-community-modules/Benchy/actions)\n\nNAME\n====\n\nBenchy - Benchmark some code\n\nSYNOPSIS\n========\n\n```raku\nuse Benchy;\n\nb 20_000,  # number of times to loop\n    { some-setup; my-old-code }, # your old version\n    { some-setup; my-new-code }, # your new version\n    { some-setup } # optional \"bare\" loop to eliminate setup code's time\n\n# SAMPLE OUTPUT:\n# Bare: 0.0606532677866851s\n# Old:  2.170558s\n# New:  0.185170s\n# NEW version is 11.72x faster\n```\n\nDESCRIPTION\n===========\n\nTakes 2 `Callable`s and measures which one is faster. Optionally takes a 3rd `Callable` that will be run the same number of times as other two callables, and the time it took to run will be subtracted from the other results.\n\nEXPORTED PRAGMAS\n================\n\nMONKEY\n------\n\nThe `use` of this module enables `MONKEY` pragma, so you can augment, use NQP, EVAL, etc, without needing to specify those pragmas.\n\nEXPORTED SUBROUTINES\n====================\n\nb(int $n, \u0026old, \u0026new, \u0026bare = { $ = $ }, :$silent)\n--------------------------------------------------\n\nBenches the codes and prints the results. Will print in colour, if [`Terminal::ANSIColor`](https://modules.raku.org/repo/Terminal::ANSIColor) is installed.\n\n### $n\n\nHow many times to loop.\n\nNote that the exact number to loop will always be evened out, as the bench splits the work into two chunks that are measured at different times, so the total time is `2 × floor ½ × $n`.\n\n### \u0026old\n\nYour \"old\" code; assumption is you have \"old\" code and you're trying to write some \"new\" code to replace it.\n\n### \u0026new\n\nYour \"new\" code.\n\n### \u0026bare\n\nOptional (defaults to `{ $ = $ }`). When specified, this `Callable` will be run same number of times as other code and the time it took to run will be subtracted from the `\u0026new` and `\u0026old` times. Use this to run some \"setup\" code. That is code that's used in `\u0026new` and `\u0026old` but should not be part of the benched times.\n\n### :$silent\n\nIf set to a truthy value, the routine will not print anything.\n\n### returns\n\nReturns a hash with three keys - `bare`, `new`, and `old` — whose values are `Duration` objects representing the time it took the corresponding `Callable`s to run. **NOTE:** the `new` and `old` already have the duration of `bare` subtracted from them.\n\n```raku\n{\n    :bare(Duration.new(\u003c32741983139/488599474770\u003e)),\n    :new(Duration.new(\u003c167/956\u003e)),\n    :old(Duration.new(\u003c1280561957330937733/590077351150947660\u003e))\n}\n```\n\nAUTHOR\n======\n\nZoffix Znet\n\nCOPYRIGHT AND LICENSE\n=====================\n\nCopyright 2017 Zoffix Znet\n\nCopyright 2018 - 2022 Raku Community\n\nThis library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraku-community-modules%2Fbenchy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraku-community-modules%2Fbenchy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraku-community-modules%2Fbenchy/lists"}