MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / runBenchmark

Function runBenchmark

benchmark/src/context-binding/context-binding.ts:87–131  ·  view source on GitHub ↗
(ctx: Context)

Source from the content-addressed store, hash-verified

85}
86
87function runBenchmark(ctx: Context) {
88 const options: Benchmark.Options = {
89 initCount: 1000,
90 onComplete: (e: Benchmark.Event) => {
91 const benchmark = e.target;
92 console.log('%s %d', benchmark, benchmark.count);
93 },
94 };
95 const suite = new Benchmark.Suite('context-bindings');
96 suite
97 .add(
98 'factory - getSync',
99 () => ctx.getSync('greeting.syncFactory'),
100 options,
101 )
102 .add('factory - get', () => ctx.get('greeting.syncFactory'), options)
103 .add('asyncFactory - get', () => ctx.get('greeting.asyncFactory'), options)
104 .add(
105 'staticProvider - getSync',
106 () => ctx.getSync('greeting.syncStaticProvider'),
107 options,
108 )
109 .add(
110 'staticProvider - get',
111 () => ctx.get('greeting.syncStaticProvider'),
112 options,
113 )
114 .add(
115 'asyncStaticProvider - get',
116 () => ctx.get('greeting.asyncStaticProvider'),
117 options,
118 )
119 .add(
120 'provider - getSync',
121 () => ctx.getSync('greeting.syncProvider'),
122 options,
123 )
124 .add('provider - get', () => ctx.get('greeting.syncProvider'), options)
125 .add(
126 'asyncProvider - get',
127 () => ctx.get('greeting.asyncProvider'),
128 options,
129 )
130 .run({async: true});
131}
132
133if (require.main === module) {
134 const ctx = setupContextBindings();

Callers 1

context-binding.tsFile · 0.70

Calls 5

getSyncMethod · 0.80
logMethod · 0.65
addMethod · 0.65
getMethod · 0.65
runMethod · 0.45

Tested by

no test coverage detected