Skip to content

Commit bb7fc22

Browse files
committed
use keepMeasuring in performance tests instead of explicit looping
1 parent 438453b commit bb7fc22

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

test/performance/logsTest.m

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,9 @@ function testEmitLogRecord(testCase)
5252
% create and emit a log record
5353
lg = opentelemetry.logs.getLogger("foo");
5454

55-
testCase.startMeasuring();
56-
% run through a loop since the time for 1 iteration is too short
57-
for i = 1:10
55+
while(testCase.keepMeasuring)
5856
emitLogRecord(lg, "info", "bar");
5957
end
60-
testCase.stopMeasuring();
6158
end
6259

6360
function testAttributes(testCase)

test/performance/metricsTest.m

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,38 +110,29 @@ function testCounterAdd(testCase)
110110
mt = opentelemetry.metrics.getMeter("foo");
111111
c = createCounter(mt, "bar");
112112

113-
testCase.startMeasuring();
114-
% run through a loop since the time for 1 iteration is too short
115-
for i = 1:10
113+
while(testCase.keepMeasuring)
116114
add(c, 5);
117115
end
118-
testCase.stopMeasuring();
119116
end
120117

121118
function testUpDownCounterAdd(testCase)
122119
% Increment an up-down-counter
123120
mt = opentelemetry.metrics.getMeter("foo");
124121
c = createUpDownCounter(mt, "bar");
125122

126-
testCase.startMeasuring();
127-
% run through a loop since the time for 1 iteration is too short
128-
for i = 1:10
123+
while(testCase.keepMeasuring)
129124
add(c, -5);
130125
end
131-
testCase.stopMeasuring();
132126
end
133127

134128
function testHistogramRecord(testCase)
135129
% record a histogram value
136130
mt = opentelemetry.metrics.getMeter("foo");
137131
h = createHistogram(mt, "bar");
138132

139-
testCase.startMeasuring();
140-
% run through a loop since the time for 1 iteration is too short
141-
for i = 1:10
133+
while(testCase.keepMeasuring)
142134
record(h, 111);
143135
end
144-
testCase.stopMeasuring();
145136
end
146137

147138
function testCounterAttributes(testCase)

0 commit comments

Comments
 (0)