OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 encoding = UTF16; | 121 encoding = UTF16; |
122 } else if (strncmp(argv[i], "--benchmark=", 12) == 0) { | 122 } else if (strncmp(argv[i], "--benchmark=", 12) == 0) { |
123 benchmark = std::string(argv[i]).substr(12); | 123 benchmark = std::string(argv[i]).substr(12); |
124 } else if (strncmp(argv[i], "--repeat=", 9) == 0) { | 124 } else if (strncmp(argv[i], "--repeat=", 9) == 0) { |
125 std::string repeat_str = std::string(argv[i]).substr(9); | 125 std::string repeat_str = std::string(argv[i]).substr(9); |
126 repeat = atoi(repeat_str.c_str()); | 126 repeat = atoi(repeat_str.c_str()); |
127 } else if (i > 0 && argv[i][0] != '-') { | 127 } else if (i > 0 && argv[i][0] != '-') { |
128 fnames.push_back(std::string(argv[i])); | 128 fnames.push_back(std::string(argv[i])); |
129 } | 129 } |
130 } | 130 } |
131 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 131 v8::Isolate* isolate = v8::Isolate::New(); |
132 { | 132 { |
| 133 v8::Isolate::Scope isolate_scope(isolate); |
133 v8::HandleScope handle_scope(isolate); | 134 v8::HandleScope handle_scope(isolate); |
134 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate); | 135 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate); |
135 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global); | 136 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global); |
136 ASSERT(!context.IsEmpty()); | 137 ASSERT(!context.IsEmpty()); |
137 { | 138 { |
138 v8::Context::Scope scope(context); | 139 v8::Context::Scope scope(context); |
139 double first_parse_total = 0; | 140 double first_parse_total = 0; |
140 double second_parse_total = 0; | 141 double second_parse_total = 0; |
141 for (size_t i = 0; i < fnames.size(); i++) { | 142 for (size_t i = 0; i < fnames.size(); i++) { |
142 std::pair<TimeDelta, TimeDelta> time = RunBaselineParser( | 143 std::pair<TimeDelta, TimeDelta> time = RunBaselineParser( |
143 fnames[i].c_str(), encoding, repeat, isolate, context); | 144 fnames[i].c_str(), encoding, repeat, isolate, context); |
144 first_parse_total += time.first.InMillisecondsF(); | 145 first_parse_total += time.first.InMillisecondsF(); |
145 second_parse_total += time.second.InMillisecondsF(); | 146 second_parse_total += time.second.InMillisecondsF(); |
146 } | 147 } |
147 if (benchmark.empty()) benchmark = "Baseline"; | 148 if (benchmark.empty()) benchmark = "Baseline"; |
148 printf("%s(FirstParseRunTime): %.f ms\n", benchmark.c_str(), | 149 printf("%s(FirstParseRunTime): %.f ms\n", benchmark.c_str(), |
149 first_parse_total); | 150 first_parse_total); |
150 printf("%s(SecondParseRunTime): %.f ms\n", benchmark.c_str(), | 151 printf("%s(SecondParseRunTime): %.f ms\n", benchmark.c_str(), |
151 second_parse_total); | 152 second_parse_total); |
152 } | 153 } |
153 } | 154 } |
154 v8::V8::Dispose(); | 155 v8::V8::Dispose(); |
155 return 0; | 156 return 0; |
156 } | 157 } |
OLD | NEW |