File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed
docs/spectator/lang/nodejs Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change 55Test maximum single-threaded throughput for two minutes.
66
77``` javascript
8- // tbd
8+ #! / usr/ bin/ env node
9+
10+ import {Registry } from " nflx-spectator" ;
11+
12+ // default is udp
13+ const registry = new Registry ();
14+ const tags = {" location" : " udp" , " version" : " correct-horse-battery-staple" };
15+
16+ const max_duration = 2 * 60 ;
17+ const start = performance .now ();
18+
19+ function elapsed () {
20+ return ((performance .now () - start) / 1000 ).toFixed (2 );
21+ }
22+
23+ console .log (" start spectator-js udp benchmark" );
24+ let iteration = 1 ;
25+ while (true ) {
26+ // without await, a heap limit allocation fail error will occur around 5.5M iterations (34 sec)
27+ await registry .counter (" spectator-js.publish" , tags).increment ();
28+ if (iteration % 500000 === 0 ) {
29+ console .log (" iterations" , iteration, " elapsed" , elapsed ());
30+ if (elapsed () > max_duration) {
31+ break ;
32+ }
33+ }
34+ iteration += 1 ;
35+ }
36+
37+ console .log (" iterations" , iteration, " rate/sec" , iteration/ elapsed ());
938```
1039
1140## Results
You can’t perform that action at this time.
0 commit comments