{"id":35013592,"url":"https://github.com/beyond-the-cloud-dev/apex-code-benchmarking","last_synced_at":"2026-03-15T22:17:01.265Z","repository":{"id":184400657,"uuid":"597835980","full_name":"beyond-the-cloud-dev/apex-code-benchmarking","owner":"beyond-the-cloud-dev","description":null,"archived":false,"fork":false,"pushed_at":"2023-03-13T21:24:44.000Z","size":172,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-28T18:53:37.374Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Apex","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beyond-the-cloud-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-02-05T19:25:27.000Z","updated_at":"2024-04-15T14:03:40.000Z","dependencies_parsed_at":"2023-07-28T09:49:50.980Z","dependency_job_id":null,"html_url":"https://github.com/beyond-the-cloud-dev/apex-code-benchmarking","commit_stats":null,"previous_names":["beyond-the-cloud-dev/apex-code-benchmarking"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/beyond-the-cloud-dev/apex-code-benchmarking","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyond-the-cloud-dev%2Fapex-code-benchmarking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyond-the-cloud-dev%2Fapex-code-benchmarking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyond-the-cloud-dev%2Fapex-code-benchmarking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyond-the-cloud-dev%2Fapex-code-benchmarking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beyond-the-cloud-dev","download_url":"https://codeload.github.com/beyond-the-cloud-dev/apex-code-benchmarking/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyond-the-cloud-dev%2Fapex-code-benchmarking/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30552658,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-15T15:03:43.933Z","status":"ssl_error","status_checked_at":"2026-03-15T15:03:37.630Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2025-12-27T05:07:49.165Z","updated_at":"2026-03-15T22:17:01.225Z","avatar_url":"https://github.com/beyond-the-cloud-dev.png","language":"Apex","funding_links":[],"categories":[],"sub_categories":[],"readme":"# apex-code-benchmarking\n\nThis repo contains util class for benchmarking apex performance. It is based on the [Advanced Apex Programming](https://advancedapex.com/) book written by Dan Appleman. \n\n\n\n## How to use\n1. Deploy [BenchmarkUtilTest](force-app\\main\\default\\classes\\Utils\\BenchmarkUtilTest.cls) class to your org.\n2. Set Debug Log Level and Trace flag as following:\n\n| Log Category   | Log Level     |\n| -------------- | ------------- |\n| Apex Code      | ERROR         |\n| Apex Profiling | NONE          |\n| Callout        | NONE          |\n| Database       | NONE          |\n| System         | NONE          |\n| Validation     | NONE          |\n| Visualforce    | NONE          |\n| Workflow       | NONE          |\n\n3. Write a test checking performance of your operation:\n\n```java\n    //get instance of BenchmarkUtil\n    BenchmarkUtilTest b = new BenchmarkUtilTest();\n\n    //set the number of loops (how many times the operation will be repeated)\n    //the more loops the more accurate the result\n    Integer loops = 1000000;\n\n    //set reference operation, If you want to compare the performance of two operations \n    b.markReferenceStartTime();\n    for(Integer i = 0; i \u003c loops; i++) {\n        //your reference operation\n        //if you want just to measure the performance of one operation, leave this loop empty.\n        //(do not remove it, to get more accurate results) \n    }\n    b.markReferenceEndTime();\n\n    // target operation, or second operation to compare\n    b.markTargetStartTime();\n    for(Integer i=0; i\u003c loops; i++) {\n        //your target operation\n    }\n    b.markTargetEndTime();\n\n    // Debug the results\n    b.reportResults(loops);\n\n```\n\n4. Run the test and check the debug log for the results\n\n```\nUSER_DEBUG [36]|ERROR|Reference Duration: 574 Target duration: 600 Benchmark Results: 26ms or 0.026 μs per operation \n```\n\n## Examples\nCheck the [CompareIncrementation](force-app\\main\\default\\classes\\Tests\\CompareIncrementation.cls) class for example of comparing performance of incrementation operations.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeyond-the-cloud-dev%2Fapex-code-benchmarking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeyond-the-cloud-dev%2Fapex-code-benchmarking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeyond-the-cloud-dev%2Fapex-code-benchmarking/lists"}