-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce memory allocations/improve perf of Gauge
- Loading branch information
Showing
4 changed files
with
87 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict'; | ||
|
||
const { getLabelNames, labelCombinationFactory } = require('./utils/labels'); | ||
|
||
module.exports = setupGaugeSuite; | ||
|
||
function setupGaugeSuite(suite) { | ||
suite.add( | ||
'inc', | ||
labelCombinationFactory([], (client, { Gauge }, labels) => | ||
Gauge.inc(labels, 1), | ||
), | ||
{ teardown, setup: setup(0) }, | ||
); | ||
|
||
suite.add( | ||
'inc with labels', | ||
labelCombinationFactory([8, 8], (client, { Gauge }, labels) => | ||
Gauge.inc(labels, 1), | ||
), | ||
{ teardown, setup: setup(2) }, | ||
); | ||
} | ||
|
||
function setup(labelCount) { | ||
return client => { | ||
const registry = new client.Registry(); | ||
|
||
const Gauge = new client.Gauge({ | ||
name: 'Gauge', | ||
help: 'Gauge', | ||
labelNames: getLabelNames(labelCount), | ||
registers: [registry], | ||
}); | ||
|
||
return { registry, Gauge }; | ||
}; | ||
} | ||
|
||
function teardown(client, { registry }) { | ||
registry.clear(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters