{"id":16310960,"url":"https://github.com/lancew/scientistp6","last_synced_at":"2025-10-25T16:31:02.103Z","repository":{"id":45892507,"uuid":"52693037","full_name":"lancew/ScientistP6","owner":"lancew","description":"Raku Scientist","archived":false,"fork":false,"pushed_at":"2022-10-26T14:45:15.000Z","size":45,"stargazers_count":6,"open_issues_count":1,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-31T08:51:16.218Z","etag":null,"topics":["raku"],"latest_commit_sha":null,"homepage":"","language":"Raku","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lancew.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}},"created_at":"2016-02-27T22:59:18.000Z","updated_at":"2023-04-01T12:39:31.000Z","dependencies_parsed_at":"2023-01-20T06:48:43.574Z","dependency_job_id":null,"html_url":"https://github.com/lancew/ScientistP6","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/lancew%2FScientistP6","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lancew%2FScientistP6/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lancew%2FScientistP6/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lancew%2FScientistP6/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lancew","download_url":"https://codeload.github.com/lancew/ScientistP6/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238174170,"owners_count":19428636,"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":["raku"],"created_at":"2024-10-10T21:43:19.655Z","updated_at":"2025-10-25T16:31:01.774Z","avatar_url":"https://github.com/lancew.png","language":"Raku","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DESCRIPTION\n\nRaku module inspired by [GitHub's Scientist](https://github.com/github/scientist) ([announcement](https://github.blog/2016-02-03-scientist/)).\n\nSee also: [Test::Lab](https://raku.land/github:MadcapJake/Test::Lab) for a different take on the same idea.\n\n[![test](https://github.com/lancew/ScientistP6/actions/workflows/test.yml/badge.svg)](https://github.com/lancew/ScientistP6/actions/workflows/test.yml)\n\n# SYNOPSIS\n\n```mermaid\nflowchart LR\n    raku[$exp.run]\n         --\u003e|execute| use(Control Code)\n         --\u003e compare(Compare Result)\n\n    raku --\u003e|execute| try(Candidate Code)\n         --\u003e compare(Compare Result)\n\n    use --\u003e return[Return Result]\n\n    compare --\u003e|publish| Metrics\n```\n\n```raku\nuse Scientist;\n\nmy $experiment = Scientist.new(\n    experiment =\u003e 'Tree',\n    try =\u003e sub {return 99},\n    use =\u003e sub {return 10},\n);\n\nmy $answer = $experiment.run;\n\nsay \"The number ten is $answer\";\nwarn 'There was a mismatch between control and candidate'\n    if $test.result{'mismatched'};\n```\n\n# Introduction\n\nThis module is inspired by the Scientist ruby code released by GitHub under the MIT license in 2015/2016.\n\nIn February 2016 I started writing the Perl5 module to bring similar ideas to Perl. Later I started this module to apply same ideas in Raku.\n\nPlease get involved in this module; contact lancew@cpan.org with ideas, suggestions; support, etc.\n\nThis code is also released under the MIT license to match the original Ruby implementation.\n\n# Methods / Attributes\n\n## context(\u003cHASHREF\u003e)\n\nProvide contextual information for the experiment; will be returned in the result set.\n\nShould be a hashref\n\n## enabled(\u003cTRUE\u003e|\u003cFALSE\u003e)\n\nDEFAULT : TRUE\nBoolean switch to enable or disable the experiment. If disabled the experiment will only return\nthe control code (use) result. The candidate code (try) will NOT be executed. The results set will\nnot be populated.\n\n## experiment(\u003cSTRING\u003e)\n\nSimply the name of the experiment included in the result set.\n\n## publish\n\nPublish is a method called by -\u003erun().\n\nScientist is design so that you create your own personalised My::Scientist module and extend publish to do what you want/need.\nFor example push timing and mismathc information to Statsd.\n\n## use(\u003cCODEREF\u003e)\n\nControl code to be included in the experiment.\nThis code will be executed and returned when the experiment is run.\nNB: This code is run and returned even if experiment enabed=false.\n\n## run()\n\nThis method executes the control (use) code and if experiment enabled will also run the candidate (try)\ncode. The control and candidate code is run in random order.\n\n## try(\u003cCODEREF\u003e)\n\nCandidate code to be included in the experiment.\nThis code will be executed and discarded when the experiment is run.\n\n# Extending Publish\n\nTo automate reporting of experiement results, you will want to write your own .publish() method. Publish is called by .run().\n\nA typical example would be to push timing information to Statsd or a database.\n\n```raku\nuse Scientist;\n\nclass MyScientist is Scientist {\n    has $.test_value is rw;\n    method publish {\n        # Do Stuff...\n    }\n}\n\nmy $experiment = MyScientist.new(\n    experiment =\u003e 'Tree',\n    enabled =\u003e True,\n    try =\u003e sub {return 99},\n    use =\u003e sub {return 88},\n);\n```\n\n# AUTHOR\n\nLance Wicks \u003clancew@cpan.org\u003e\n\n# COPYRIGHT AND LICENSE\n\nThis software is Copyright (c) 2016 by Lance Wicks.\n\nThis is free software, licensed under:\n\n  The MIT (X11) License\n\nThe MIT License\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated\ndocumentation files (the \"Software\"), to deal in the Software\nwithout restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense,\nand/or sell copies of the Software, and to permit persons to\nwhom the Software is furnished to do so, subject to the\nfollowing conditions:\n\nThe above copyright notice and this permission notice shall\nbe included in all copies or substantial portions of the\nSoftware.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT\nWARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\nINCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR\nPURPOSE AND NONINFRINGEMENT. IN NO EVENT\nSHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\n# SEE ALSO\n\nhttp://www.infoq.com/news/2016/02/github-scientist-refactoring\n\nhttp://githubengineering.com/scientist/\n\nhttps://news.ycombinator.com/item?id=11104781\n\nhttps://github.com/ziyasal/scientist.js\n\nhttp://tech-blog.cv-library.co.uk/2016/03/03/introducing-scientist/\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flancew%2Fscientistp6","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flancew%2Fscientistp6","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flancew%2Fscientistp6/lists"}