Skip to content

Commit 51124f2

Browse files
committed
Faster matlab parseintperf
sprintf/sscanf are much faster dec2hex/hex2dec which have lots of input checking.
1 parent 8ada3cf commit 51124f2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

test/perf/micro/perf.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ function timeit(name, func, varargin)
9292
function n = parseintperf(t)
9393
for i = 1:t
9494
n = randi([0,2^32-1],1,'uint32');
95-
s = dec2hex(n);
96-
m = hex2dec(s);
95+
s = sprintf('%08X',n);
96+
m = sscanf(s,'%X');
9797
assert(m == n);
9898
end
9999
end

0 commit comments

Comments
 (0)