OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart 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 file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/benchmark_test.h" | 5 #include "vm/benchmark_test.h" |
6 | 6 |
7 #include "bin/builtin.h" | 7 #include "bin/builtin.h" |
8 #include "bin/file.h" | 8 #include "bin/file.h" |
9 #include "bin/isolate_data.h" | 9 #include "bin/isolate_data.h" |
10 #include "bin/process.h" | 10 #include "bin/process.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 Benchmark* Benchmark::first_ = NULL; | 27 Benchmark* Benchmark::first_ = NULL; |
28 Benchmark* Benchmark::tail_ = NULL; | 28 Benchmark* Benchmark::tail_ = NULL; |
29 const char* Benchmark::executable_ = NULL; | 29 const char* Benchmark::executable_ = NULL; |
30 | 30 |
31 // | 31 // |
32 // Measure compile of all dart2js(compiler) functions. | 32 // Measure compile of all dart2js(compiler) functions. |
33 // | 33 // |
34 static char* ComputeDart2JSPath(const char* arg) { | 34 static char* ComputeDart2JSPath(const char* arg) { |
35 char buffer[2048]; | 35 char buffer[2048]; |
36 char* dart2js_path = strdup(File::GetCanonicalPath(arg)); | 36 char* dart2js_path = strdup(File::GetCanonicalPath(NULL, arg)); |
37 const char* compiler_path = "%s%spkg%scompiler%slib%scompiler.dart"; | 37 const char* compiler_path = "%s%spkg%scompiler%slib%scompiler.dart"; |
38 const char* path_separator = File::PathSeparator(); | 38 const char* path_separator = File::PathSeparator(); |
39 ASSERT(path_separator != NULL && strlen(path_separator) == 1); | 39 ASSERT(path_separator != NULL && strlen(path_separator) == 1); |
40 char* ptr = strrchr(dart2js_path, *path_separator); | 40 char* ptr = strrchr(dart2js_path, *path_separator); |
41 while (ptr != NULL) { | 41 while (ptr != NULL) { |
42 *ptr = '\0'; | 42 *ptr = '\0'; |
43 OS::SNPrint(buffer, 2048, compiler_path, dart2js_path, path_separator, | 43 OS::SNPrint(buffer, 2048, compiler_path, dart2js_path, path_separator, |
44 path_separator, path_separator, path_separator, path_separator); | 44 path_separator, path_separator, path_separator, path_separator); |
45 if (File::Exists(buffer)) { | 45 if (File::Exists(NULL, buffer)) { |
46 break; | 46 break; |
47 } | 47 } |
48 ptr = strrchr(dart2js_path, *path_separator); | 48 ptr = strrchr(dart2js_path, *path_separator); |
49 } | 49 } |
50 if (ptr == NULL) { | 50 if (ptr == NULL) { |
51 free(dart2js_path); | 51 free(dart2js_path); |
52 dart2js_path = NULL; | 52 dart2js_path = NULL; |
53 } | 53 } |
54 return dart2js_path; | 54 return dart2js_path; |
55 } | 55 } |
(...skipping 11 matching lines...) Expand all Loading... |
67 static void SetupDart2JSPackagePath() { | 67 static void SetupDart2JSPackagePath() { |
68 bool worked = bin::DartUtils::SetOriginalWorkingDirectory(); | 68 bool worked = bin::DartUtils::SetOriginalWorkingDirectory(); |
69 EXPECT(worked); | 69 EXPECT(worked); |
70 | 70 |
71 Dart_Handle result = bin::DartUtils::PrepareForScriptLoading(false, false); | 71 Dart_Handle result = bin::DartUtils::PrepareForScriptLoading(false, false); |
72 DART_CHECK_VALID(result); | 72 DART_CHECK_VALID(result); |
73 | 73 |
74 // Setup package root. | 74 // Setup package root. |
75 char buffer[2048]; | 75 char buffer[2048]; |
76 char* executable_path = | 76 char* executable_path = |
77 strdup(File::GetCanonicalPath(Benchmark::Executable())); | 77 strdup(File::GetCanonicalPath(NULL, Benchmark::Executable())); |
78 const char* packages_path = "%s%s..%spackages"; | 78 const char* packages_path = "%s%s..%spackages"; |
79 const char* path_separator = File::PathSeparator(); | 79 const char* path_separator = File::PathSeparator(); |
80 OS::SNPrint(buffer, 2048, packages_path, executable_path, path_separator, | 80 OS::SNPrint(buffer, 2048, packages_path, executable_path, path_separator, |
81 path_separator); | 81 path_separator); |
82 result = bin::DartUtils::SetupPackageRoot(buffer, NULL); | 82 result = bin::DartUtils::SetupPackageRoot(buffer, NULL); |
83 DART_CHECK_VALID(result); | 83 DART_CHECK_VALID(result); |
84 } | 84 } |
85 | 85 |
86 void Benchmark::RunAll(const char* executable) { | 86 void Benchmark::RunAll(const char* executable) { |
87 SetExecutable(executable); | 87 SetExecutable(executable); |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 timer.Stop(); | 700 timer.Stop(); |
701 int64_t elapsed_time = timer.TotalElapsedTime(); | 701 int64_t elapsed_time = timer.TotalElapsedTime(); |
702 benchmark->set_score(elapsed_time); | 702 benchmark->set_score(elapsed_time); |
703 } | 703 } |
704 | 704 |
705 BENCHMARK_MEMORY(InitialRSS) { | 705 BENCHMARK_MEMORY(InitialRSS) { |
706 benchmark->set_score(bin::Process::MaxRSS()); | 706 benchmark->set_score(bin::Process::MaxRSS()); |
707 } | 707 } |
708 | 708 |
709 } // namespace dart | 709 } // namespace dart |
OLD | NEW |