Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Example development environment with three patterns for benchmarking Cloudflare edge workers.

Notifications You must be signed in to change notification settings

EverlastingBugstopper/cf-workers-benchmark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cloudflare Workers Time Tests

Usage

npm run install
npm run build

Identifying Bottleneck Functions

If you want to get into the weeds

This setup is most useful when you are trying to trace down where the most CPU time is going. It runs in the node environment, so don't expect its output to be realistic in production. You can change what function to time in time.js. njstrace runs by hijacking the compile method and tracks the time of nested functions as well.

$ npm run transpile
$ npm run time:bottleneck
                     _getHello @ response.js            0ms
                     _getWorld @ response.js            0ms
                   getResponse @ response.js            2ms

If you don't want to use Babel

Use this if you want a quick and dirty way to start timing things.

Note that this runs in the preview environment, which is ~5x faster than production. This can be used for smaller measurements without Babel.

console.time('func');
await func();
console.timeEnd('func');
npm run build
npm run time:preview

Testing production requests

Use this if want to see how long your requests take. The number of milliseconds is simply the time spent waiting for the entire request to complete. This uses Date.now() and is tied to the fetch event request, so this is about as helpful as just using the network tab for requests.

This setup assumes you have deployed the worker you want to time to production.

npm run build
npm run time:request

About

Example development environment with three patterns for benchmarking Cloudflare edge workers.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published