-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathTest_plotlyfig_perf.m
More file actions
53 lines (46 loc) · 1.62 KB
/
Test_plotlyfig_perf.m
File metadata and controls
53 lines (46 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
classdef Test_plotlyfig_perf < matlab.perftest.TestCase
% Run as:
%{
res = runperf("Test_plotlyfig_perf");
tb = res.sampleSummary;
%}
methods (Test)
function testManySubplotsConversionTime(tc)
% Stress test: many subplots with multiple lines each.
nAxes = 10;
nLinesPerAxis = 10;
fig = figure("Visible", "off");
for a = 1:nAxes
subplot(4, 5, a);
for ln = 1:nLinesPerAxis
plot(1:50, rand(1, 50));
hold on;
end
hold off;
end
while tc.keepMeasuring
p = plotlyfig(fig, "visible", "off");
end
% Verify correctness: one trace per line
tc.verifyNumElements(p.data, nAxes * nLinesPerAxis);
% Verify all traces are scatter type
for k = 1:numel(p.data)
tc.verifyEqual(p.data{k}.type, "scatter", ...
sprintf("Trace %d should be scatter", k));
end
end
function testCheckescapeLongString(tc)
% Stress test for checkescape with a long string containing
% many characters that need escaping. The old char-shift
% implementation was O(n^2); strrep is O(n).
n = 100000;
val = repmat('a"b\c/d', 1, n);
while tc.keepMeasuring
result = checkescape(val);
end
% Verify correctness
tc.verifyEqual(length(result), 10 * n);
tc.verifyTrue(startsWith(result, 'a\"b\\c\/d'));
end
end
end