summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel GOUGEON <sgougeon@free.fr>2016-10-15 21:56:44 +0200
committerAntoine ELIAS <antoine.elias@scilab-enterprises.com>2016-11-04 15:45:49 +0100
commitb7a625bc2d7871ddd60f03f51dfba48321ba4261 (patch)
tree662cedf0aaa97baf05f3be6ec05b863fa9467fd9
parentd8fbf3ee91e301cd5054535603b9f98b01dd7d21 (diff)
downloadscilab-b7a625bc2d7871ddd60f03f51dfba48321ba4261.zip
scilab-b7a625bc2d7871ddd60f03f51dfba48321ba4261.tar.gz
evstr() was very slow: vectorized. benchmark added
Change-Id: If40bffc46adaaab443295b2ec1e9c3daa36f73a1
-rw-r--r--scilab/modules/string/macros/evstr.sci4
-rw-r--r--scilab/modules/string/tests/benchmarks/bench_evstr.tst15
2 files changed, 16 insertions, 3 deletions
diff --git a/scilab/modules/string/macros/evstr.sci b/scilab/modules/string/macros/evstr.sci
index 909322b..5f801af 100644
--- a/scilab/modules/string/macros/evstr.sci
+++ b/scilab/modules/string/macros/evstr.sci
@@ -42,9 +42,7 @@ function [%val, %ierr] = evstr(%str)
42 INF = %inf; 42 INF = %inf;
43 end 43 end
44 44
45 for %l = 1:size(%str, "r") 45 %t1 = strcat(%str, ",", "c")+";"
46 %t1(%l) = strcat(%str(%l, :), ",") + ";"
47 end
48 %t1(1) = "%val=[" + %t1(1); 46 %t1(1) = "%val=[" + %t1(1);
49 %t1($) = part(%t1($), 1:length(%t1($)) - 1)+";"; 47 %t1($) = part(%t1($), 1:length(%t1($)) - 1)+";";
50 %t1($+1)="]"; 48 %t1($+1)="]";
diff --git a/scilab/modules/string/tests/benchmarks/bench_evstr.tst b/scilab/modules/string/tests/benchmarks/bench_evstr.tst
new file mode 100644
index 0000000..e8ce950
--- /dev/null
+++ b/scilab/modules/string/tests/benchmarks/bench_evstr.tst
@@ -0,0 +1,15 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2016 - Samuel GOUGEON <sgougeon@free.fr>
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7
8// Benchmark test for evstr function
9m = rand(5000, 5);
10s = string(m);
11
12// <-- BENCH NB RUN : 10 -->
13// <-- BENCH START -->
14e = evstr(s);
15// <-- BENCH END -->