Skip to content

Commit 69947da

Browse files
mayurkale22dyladanOlivierAlbertini
authored
Add benchmark README and latest numbers (open-telemetry#689)
* add benchmark README and latest numbers * chore: update readme chore: update readme * chore: update readme chore: update readme * chore: update benchmarks * generate latest benchmark numbers Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com> Co-authored-by: Olivier Albertini <olivier.albertini@montreal.ca>
1 parent d3af8c4 commit 69947da

5 files changed

Lines changed: 92 additions & 31 deletions

File tree

benchmark/README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Benchmarks
2+
3+
## How to run
4+
5+
To run your benchmark, just:
6+
```sh
7+
$ npm run bench
8+
```
9+
10+
The minimum sample size is set to 10 to perform statistical analysis on benchmark, you can re-configure that in `benchmark.js`.
11+
12+
> NOTE: If you're interested in writing benchmark for other APIs, please write a benchmark in the `benchmark/index.js` module. Please refer to the `benchmark/tracer.js` or `benchmark/propagator.js` for more comprehensive examples.
13+
14+
## Results
15+
16+
### `v0.3.3` release
17+
18+
```
19+
Beginning NoopTracerRegistry Benchmark...
20+
5 tests completed.
21+
22+
#startSpan x 731,516,636 ops/sec ±2.57% (20 runs sampled)
23+
#startSpan:parent x 744,353,590 ops/sec ±3.03% (20 runs sampled)
24+
#startSpan with attribute x 737,451,332 ops/sec ±3.75% (20 runs sampled)
25+
#startSpan with 30 attributes x 1,658,688 ops/sec ±1.23% (20 runs sampled)
26+
#startSpan with 100 attributes x 535,082 ops/sec ±1.55% (20 runs sampled)
27+
28+
Beginning BasicTracerRegistry Benchmark...
29+
5 tests completed.
30+
31+
#startSpan x 80,633 ops/sec ±3.57% (20 runs sampled)
32+
#startSpan:parent x 56,228 ops/sec ±2.18% (20 runs sampled)
33+
#startSpan with attribute x 86,710 ops/sec ±1.80% (20 runs sampled)
34+
#startSpan with 30 attributes x 36,331 ops/sec ±1.29% (20 runs sampled)
35+
#startSpan with 100 attributes x 3,549 ops/sec ±3.59% (20 runs sampled)
36+
37+
Beginning BasicTracerRegistry with SimpleSpanProcessor Benchmark...
38+
5 tests completed.
39+
40+
#startSpan x 74,539 ops/sec ±4.49% (20 runs sampled)
41+
#startSpan:parent x 48,953 ops/sec ±4.98% (20 runs sampled)
42+
#startSpan with attribute x 79,686 ops/sec ±2.54% (20 runs sampled)
43+
#startSpan with 30 attributes x 26,491 ops/sec ±13.68% (20 runs sampled)
44+
#startSpan with 100 attributes x 2,464 ops/sec ±19.64% (20 runs sampled)
45+
46+
Beginning BasicTracerRegistry with BatchSpanProcessor Benchmark...
47+
5 tests completed.
48+
49+
#startSpan x 74,974 ops/sec ±3.57% (20 runs sampled)
50+
#startSpan:parent x 42,390 ops/sec ±20.68% (20 runs sampled)
51+
#startSpan with attribute x 76,497 ops/sec ±2.93% (20 runs sampled)
52+
#startSpan with 30 attributes x 33,042 ops/sec ±2.03% (20 runs sampled)
53+
#startSpan with 100 attributes x 3,459 ops/sec ±4.56% (20 runs sampled)
54+
55+
56+
Beginning B3Format Benchmark...
57+
2 tests completed.
58+
59+
#Inject x 5,086,366 ops/sec ±3.18% (100 runs sampled)
60+
#Extract x 4,859,557 ops/sec ±3.80% (100 runs sampled)
61+
62+
Beginning HttpTraceContext Benchmark...
63+
2 tests completed.
64+
65+
#Inject x 13,660,710 ops/sec ±1.84% (100 runs sampled)
66+
#Extract x 1,692,010 ops/sec ±0.83% (100 runs sampled)
67+
```

benchmark/benchmark.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ const Benchmark = require('benchmark');
44
const benchmarks = require('beautify-benchmark');
55

66
Benchmark.options.maxTime = 0;
7-
// @todo : Change it to between 50-100 or keep it random.
8-
Benchmark.options.minSamples = 10;
97

10-
module.exports = () => {
8+
module.exports = (minSamples) => {
9+
Benchmark.options.minSamples = minSamples;
1110
const suite = new Benchmark.Suite();
1211

1312
return suite

benchmark/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
const execSync = require('child_process').execSync;
44
const exec = cmd => execSync(cmd, { stdio: [0, 1, 2] });
55

6-
exec('node benchmark/tracer');
7-
exec('node benchmark/propagator');
6+
exec('node benchmark/tracer.js');
7+
exec('node benchmark/propagator.js');

benchmark/propagator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const benchmark = require('./benchmark');
4-
const opentelemetry = require('@opentelemetry/core');
4+
const opentelemetry = require('../packages/opentelemetry-core');
55

66
const setups = [
77
{
@@ -26,7 +26,7 @@ const setups = [
2626
for (const setup of setups) {
2727
console.log(`Beginning ${setup.name} Benchmark...`);
2828
const propagator = setup.propagator;
29-
const suite = benchmark()
29+
const suite = benchmark(100)
3030
.add('#Inject', function () {
3131
propagator.inject({
3232
traceId: 'd4cda95b652f4a1592b449d5929fda1b',

benchmark/tracer.js

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
'use strict';
22

33
const benchmark = require('./benchmark');
4-
const opentelemetry = require('@opentelemetry/core');
5-
const { BasicTracerRegistry, BatchSpanProcessor, InMemorySpanExporter, SimpleSpanProcessor } = require('@opentelemetry/tracing');
6-
const { NodeTracerRegistry } = require('@opentelemetry/node');
4+
const opentelemetry = require('../packages/opentelemetry-core');
5+
const { BasicTracerRegistry, BatchSpanProcessor, InMemorySpanExporter, SimpleSpanProcessor } = require('../packages/opentelemetry-tracing');
76

8-
const exporter = new InMemorySpanExporter();
97
const logger = new opentelemetry.NoopLogger();
108

119
const setups = [
10+
{
11+
name: 'NoopTracerRegistry',
12+
registry: opentelemetry.getTracerRegistry()
13+
},
1214
{
1315
name: 'BasicTracerRegistry',
1416
registry: new BasicTracerRegistry({ logger })
1517
},
1618
{
17-
name: 'NodeTracerRegistry',
18-
registry: new NodeTracerRegistry({ logger })
19+
name: 'BasicTracerRegistry with SimpleSpanProcessor',
20+
registry: getRegistry(new SimpleSpanProcessor(new InMemorySpanExporter()))
21+
},
22+
{
23+
name: 'BasicTracerRegistry with BatchSpanProcessor',
24+
registry: getRegistry(new BatchSpanProcessor(new InMemorySpanExporter()))
1925
}
2026
];
2127

2228
for (const setup of setups) {
2329
console.log(`Beginning ${setup.name} Benchmark...`);
2430
const tracer = setup.registry.getTracer("benchmark");
25-
const suite = benchmark()
31+
const suite = benchmark(20)
2632
.add('#startSpan', function () {
2733
const span = tracer.startSpan('op');
2834
span.end();
@@ -51,25 +57,14 @@ for (const setup of setups) {
5157
span.setAttribute('attr-key-' + j, 'attr-value-' + j);
5258
}
5359
span.end();
54-
})
55-
.add('#startSpan with SimpleSpanProcessor', function () {
56-
const simpleSpanProcessor = new SimpleSpanProcessor(exporter);
57-
58-
registry.addSpanProcessor(simpleSpanProcessor);
59-
const span = tracer.startSpan('op');
60-
span.end();
61-
62-
simpleSpanProcessor.shutdown();
63-
})
64-
.add('#startSpan with BatchSpanProcessor', function () {
65-
const batchSpanProcessor = new BatchSpanProcessor(exporter);
66-
67-
registry.addSpanProcessor(batchSpanProcessor);
68-
const span = tracer.startSpan('op');
69-
span.end();
70-
batchSpanProcessor.shutdown();
7160
});
7261

7362
// run async
7463
suite.run({ async: false });
7564
}
65+
function getRegistry(processor) {
66+
const registry = new BasicTracerRegistry({ logger });
67+
registry.addSpanProcessor(processor);
68+
return registry;
69+
}
70+

0 commit comments

Comments
 (0)