Nicolas asked me the following questions and I was stuck :)
Stef I have been doing some file intensive activities and found my program to be very slow. Just to be sure I ran them in Java and found it was much faster So I did a small test: --- i := 0. '/home/anquetil/Documents/RMod/Tools/workspace/Blocks/jfreechart-0_9_0.mse' asFileReference readStream contents do: [ :c | i:= i+1]. --- 10 times with TimeProfiler : 14.436 sec 10 times as a script passed to pharo-vm-nox (latest 4.0 image) : 16.07 sec similar thing (as far as I can tell) 10 times in java: 1.482 sec. --- public static void main(String[] args) { int length =0; try { String filename = "/home/anquetil/Documents/RMod/Tools/workspace/Blocks/jfreechart-0_9_0.mse"; String content = new String(Files.readAllBytes(Paths.get(filename)), "UTF8"); for (int i=0; i < content.length(); i++) { content.charAt(i); length = length+1; } } catch (IOException e) { e.printStackTrace(); } System.out.println(length); } --- is this known ? normal? nicolas PS: time for java and pharo script or measured as: $ for i in 1 2 3 4 5 6 7 8 9 10; do time run-experiment; done |
You are measuring image startup time, not the actual code.
'bar.txt' asFileReference writeStreamDo: [ :out | 10000 timesRepeat: [ out << Character alphabet; crlf ] ]. [ 'bar.txt' asFileReference contents ] bench. "37.296 per second" [ 'bar.txt' asFileReference contents ] timeToRun. "0:00:00:00.022" So reading a 260Kb file is pretty fast. Image startup is 0.5 seconds at best (headless, linux) in my experience. > On 15 Mar 2015, at 22:34, stepharo <[hidden email]> wrote: > > Nicolas asked me the following questions and I was stuck :) > > Stef > > I have been doing some file intensive activities and found my program to be very slow. > Just to be sure I ran them in Java and found it was much faster > > So I did a small test: > --- > i := 0. > '/home/anquetil/Documents/RMod/Tools/workspace/Blocks/jfreechart-0_9_0.mse' asFileReference readStream contents do: [ :c | i:= i+1]. > --- > > 10 times with TimeProfiler : 14.436 sec > 10 times as a script passed to pharo-vm-nox (latest 4.0 image) : 16.07 sec > > similar thing (as far as I can tell) 10 times in java: 1.482 sec. > --- > public static void main(String[] args) { > int length =0; > try { > String filename = "/home/anquetil/Documents/RMod/Tools/workspace/Blocks/jfreechart-0_9_0.mse"; > String content = new String(Files.readAllBytes(Paths.get(filename)), "UTF8"); > for (int i=0; i < content.length(); i++) { > content.charAt(i); > length = length+1; > } > } catch (IOException e) { > e.printStackTrace(); > } > System.out.println(length); > } > --- > > is this known ? normal? > > nicolas > > PS: time for java and pharo script or measured as: > $ for i in 1 2 3 4 5 6 7 8 9 10; do time run-experiment; done > > |
Free forum by Nabble | Edit this page |