OLD | NEW |
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 import fletch.*; | 5 import dartino.*; |
6 | 6 |
7 import java.io.FileInputStream; | 7 import java.io.FileInputStream; |
8 import java.io.FileNotFoundException; | 8 import java.io.FileNotFoundException; |
9 import java.io.IOException; | 9 import java.io.IOException; |
10 | 10 |
11 import java.util.List; | 11 import java.util.List; |
12 | 12 |
13 class PerformanceTest { | 13 class PerformanceTest { |
14 static final int CALL_COUNT = 10000; | 14 static final int CALL_COUNT = 10000; |
15 static final int TREE_DEPTH = 7; | 15 static final int TREE_DEPTH = 7; |
16 | 16 |
17 public static void main(String args[]) { | 17 public static void main(String args[]) { |
18 // Expecting a snapshot of the dart service code on the command line. | 18 // Expecting a snapshot of the dart service code on the command line. |
19 if (args.length != 1) { | 19 if (args.length != 1) { |
20 System.out.println("Usage: java PerformanceTest <snapshot>"); | 20 System.out.println("Usage: java PerformanceTest <snapshot>"); |
21 System.exit(1); | 21 System.exit(1); |
22 } | 22 } |
23 | 23 |
24 // Load libfletch.so. | 24 // Load libdartino.so. |
25 System.loadLibrary("fletch"); | 25 System.loadLibrary("dartino"); |
26 | 26 |
27 // Setup Fletch. | 27 // Setup Dartino. |
28 FletchApi.Setup(); | 28 DartinoApi.Setup(); |
29 FletchServiceApi.Setup(); | 29 DartinoServiceApi.Setup(); |
30 FletchApi.AddDefaultSharedLibrary("libfletch.so"); | 30 DartinoApi.AddDefaultSharedLibrary("libdartino.so"); |
31 | 31 |
32 try { | 32 try { |
33 // Load snapshot and start dart code on a separate thread. | 33 // Load snapshot and start dart code on a separate thread. |
34 FileInputStream snapshotStream = new FileInputStream(args[0]); | 34 FileInputStream snapshotStream = new FileInputStream(args[0]); |
35 int available = snapshotStream.available(); | 35 int available = snapshotStream.available(); |
36 byte[] snapshot = new byte[available]; | 36 byte[] snapshot = new byte[available]; |
37 snapshotStream.read(snapshot); | 37 snapshotStream.read(snapshot); |
38 Thread dartThread = new Thread(new SnapshotRunner(snapshot)); | 38 Thread dartThread = new Thread(new SnapshotRunner(snapshot)); |
39 dartThread.start(); | 39 dartThread.start(); |
40 } catch (FileNotFoundException e) { | 40 } catch (FileNotFoundException e) { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 154 |
155 start = System.currentTimeMillis(); | 155 start = System.currentTimeMillis(); |
156 for (int i = 0; i < CALL_COUNT; i++) { | 156 for (int i = 0; i < CALL_COUNT; i++) { |
157 countTreeNodes(generated); | 157 countTreeNodes(generated); |
158 } | 158 } |
159 end = System.currentTimeMillis(); | 159 end = System.currentTimeMillis(); |
160 us = (end - start) * 1000.0 / CALL_COUNT; | 160 us = (end - start) * 1000.0 / CALL_COUNT; |
161 System.out.println("Counting (Java) took " + us + " us."); | 161 System.out.println("Counting (Java) took " + us + " us."); |
162 } | 162 } |
163 } | 163 } |
OLD | NEW |