Some speed difference is to be expected, but the numbers at the end are too extreme. You are mixing micro and macro benchmarks. The micro benchmarks indicate a 10x slowdown, the macro benchmark 700x ! Maybe your algorithm is not optimally implemented in Pharo ?
On 16 Mar 2015, at 09:49, Nicolas Anquetil <nicolas.anquetil@inria.fr> wrote:
I have been doing some file intensive activities and found my program to be VERY slow (see at the end). Just to be sure I ran them in Java and found it was much faster
So I did a small test: --- [10 timesRepeat: [i := 0. '/home/anquetil/Documents/RMod/Tools/workspace/Blocks/jfreechart-0_9_0.mse' asFileReference readStream contents do: [ :c | i:= i+1]. ] ] timeToRunWithoutGC. ---
result = 12.932 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); } ---
Because my program is MUCH slower (see at the end) in Smalltalk than in Java, I did another experiment:
--- [1 to: 10 do: [:i| 1 to: 100000000 do: [:j | String new] ] ] timeToRunWithoutGC. ---
result = 33.063 sec
and in java: 4.382 sec. ---[10 runs of] public static void main(String[] args) { for (int i=0; i < 100000000; i++) { new String(); } } ---
Concretly, my need was: Take 2600 methods in a Moose model, take their source code (therefore reading files), for methods longer than 100 lines (there are 29 of them), go through there code to find the blocks (matching {}). In smalltalk it ran > 12hours and I had processed 5 methods of the 29 long ones I reimplemented in Java (basically, just changing from pharo to java syntax) and it took 1 minutes to compute everything ...
:-(
On the good side, it was much easier to program it in smalltalk (about half a day to think about the algorithm, experiement, implement, test) than in Java (another 1/2 day, just to recode the algorithm that already worked).
nicolas