{"id":17956329,"url":"https://github.com/b0o/tiktoken-bench","last_synced_at":"2026-05-01T09:31:37.222Z","repository":{"id":170520958,"uuid":"646676024","full_name":"b0o/tiktoken-bench","owner":"b0o","description":"A small Node.js benchmark suite for the tiktoken WASM port.","archived":false,"fork":false,"pushed_at":"2023-05-29T09:03:38.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-03T17:18:58.539Z","etag":null,"topics":["benchmark","gpt-3","gpt-4","machine-learning","openai","tiktoken","tokenization"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/b0o.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2023-05-29T04:56:02.000Z","updated_at":"2023-05-29T05:01:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"fb19aaa7-ae9b-4a32-bd6f-395b47a6b5cc","html_url":"https://github.com/b0o/tiktoken-bench","commit_stats":null,"previous_names":["b0o/tiktoken-bench"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/b0o/tiktoken-bench","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b0o%2Ftiktoken-bench","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b0o%2Ftiktoken-bench/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b0o%2Ftiktoken-bench/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b0o%2Ftiktoken-bench/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/b0o","download_url":"https://codeload.github.com/b0o/tiktoken-bench/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b0o%2Ftiktoken-bench/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32492108,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["benchmark","gpt-3","gpt-4","machine-learning","openai","tiktoken","tokenization"],"created_at":"2024-10-29T10:37:21.164Z","updated_at":"2026-05-01T09:31:37.207Z","avatar_url":"https://github.com/b0o.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tiktoken-bench\n\nA small Node.js benchmark suite for the [tiktoken](https://github.com/dqbd/tiktoken) WASM port.\n\nIt compares the performance of tiktoken on the main thread verus worker threads using [threads.js](https://github.com/andywer/threads.js).\n\n[Benchmark.js](https://github.com/bestiejs/benchmark.js) is used for benchmarking.\n\n## Purpose\n\nThe main purpose for writing this benchmark suite was to determine if it's worth offloading tokenization onto a worker thread, in the context of a Node.js web server. We've determined that, for our use-case, tiktoken is performant enough to run on the main thread.\n\n## Benchmarks\n\nThese benchmarks are based on tiktoken `1.0.7`, and were run on a Linux desktop with an AMD Ryzen Threadripper 1950x and 64GB RAM:\n\n```\nEncoding (main thread)\n  id:             enc-main\n  workers:        N/a\n  iterations:     N/a\n  elapsed:        12.23sec\n  samples:        181\n  ops/sec:        293.3 ±0.64%\n  tks/sec:        276,242.6 ±1,770.0\n  tks/sec/worker: 276,242.6 ±1,770.0\n\nDecoding (main thread)\n  id:             dec-main\n  workers:        N/a\n  iterations:     N/a\n  elapsed:        12.22sec\n  samples:        188\n  ops/sec:        30,992.5 ±0.76%\n  tks/sec:        29,194,890.2 ±220,612.6\n  tks/sec/worker: 29,194,890.2 ±220,612.6\n\nEncoding (iterations) (main thread)\n  id:             enc-main-iter\n  workers:        N/a\n  iterations:     32,768\n    inner:        512\n    outer:        64\n  elapsed:        4,428.76sec\n  samples:        20\n  ops/sec:        296.2 ±0.35%\n  tks/sec:        279,049.6 ±970.0\n  tks/sec/worker: 279,049.6 ±970.0\n\nDecoding (iterations) (main thread)\n  id:             dec-main-iter\n  workers:        N/a\n  iterations:     32,768\n    inner:        512\n    outer:        64\n  elapsed:        49.35sec\n  samples:        22\n  ops/sec:        29,379.6 ±2.41%\n  tks/sec:        27,675,625.7 ±667,365.1\n  tks/sec/worker: 27,675,625.7 ±667,365.1\n\nEncoding (iterations) (worker threads)\n  id:             enc-worker-iter\n  workers:        32\n  iterations:     32,768\n    inner:        512\n    outer:        64\n  elapsed:        119.37sec\n  samples:        20\n  ops/sec:        5,503.1 ±1.50%\n  tks/sec:        5,183,936.2 ±77,661.8\n  tks/sec/worker: 161,998.0 ±2,426.9\n\nDecoding (iterations) (worker threads)\n  id:             dec-worker-iter\n  workers:        32\n  iterations:     32,768\n    inner:        512\n    outer:        64\n  elapsed:        7.25sec\n  samples:        80\n  ops/sec:        418,890.0 ±3.07%\n  tks/sec:        394,594,407.5 ±12,094,860.3\n  tks/sec/worker: 12,331,075.2 ±377,964.4\n```\n\n## Usage\n\n```bash\n$ npm install\n$ npm run bench [mode ..]\n```\n\nMode is either `main`, `main-iter`, or `worker-iter`. If unspecified, all modes are enabled.\n\n## License\n\nCopyright 2023 Maddison Hellstrom\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb0o%2Ftiktoken-bench","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fb0o%2Ftiktoken-bench","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb0o%2Ftiktoken-bench/lists"}