Skip to content

Commit 68cd632

Browse files
committed
add benchmark
1 parent 95fbcd5 commit 68cd632

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

example/BenchmarkNormalize.m

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
classdef (SharedTestFixtures={ matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))))}) ...
2+
BenchmarkNormalize < matlab.perftest.TestCase
3+
4+
properties
5+
P = './../asdf/../../././//'
6+
end
7+
8+
properties(TestParameter)
9+
backend
10+
end
11+
12+
methods (TestParameterDefinition, Static)
13+
function backend = setupBackend()
14+
backend = init_backend('normalize');
15+
end
16+
end
17+
18+
methods (Test)
19+
20+
function bench(tc, backend)
21+
tc.startMeasuring()
22+
o = stdlib.normalize(tc.P, backend);
23+
tc.stopMeasuring()
24+
25+
tc.verifyClass(o, 'string')
26+
tc.verifyGreaterThan(strlength(o), 0)
27+
end
28+
29+
30+
end
31+
32+
end

example/BenchmarkNormalizeRun.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function [r, s] = BenchmarkNormalizeRun()
2+
tname = "BenchmarkNormalize";
3+
4+
r.same = run_bench(tname);
5+
s.exist = sampleSummary(r.same);
6+
disp(sortrows(s.exist, "Median"))
7+
end
8+
9+
10+
function result = run_bench(name)
11+
suite = testsuite(name);
12+
exp = matlab.perftest.TimeExperiment.limitingSamplingError(MaxSamples=150, RelativeMarginOfError=0.05);
13+
result = exp.run(suite);
14+
end

0 commit comments

Comments
 (0)