OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 print_tokens = true; | 199 print_tokens = true; |
200 } else if (strncmp(argv[i], "--benchmark=", 12) == 0) { | 200 } else if (strncmp(argv[i], "--benchmark=", 12) == 0) { |
201 benchmark = std::string(argv[i]).substr(12); | 201 benchmark = std::string(argv[i]).substr(12); |
202 } else if (strncmp(argv[i], "--repeat=", 9) == 0) { | 202 } else if (strncmp(argv[i], "--repeat=", 9) == 0) { |
203 std::string repeat_str = std::string(argv[i]).substr(9); | 203 std::string repeat_str = std::string(argv[i]).substr(9); |
204 repeat = atoi(repeat_str.c_str()); | 204 repeat = atoi(repeat_str.c_str()); |
205 } else if (i > 0 && argv[i][0] != '-') { | 205 } else if (i > 0 && argv[i][0] != '-') { |
206 fnames.push_back(std::string(argv[i])); | 206 fnames.push_back(std::string(argv[i])); |
207 } | 207 } |
208 } | 208 } |
209 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 209 v8::Isolate* isolate = v8::Isolate::New(); |
210 { | 210 { |
| 211 v8::Isolate::Scope isolate_scope(isolate); |
211 v8::HandleScope handle_scope(isolate); | 212 v8::HandleScope handle_scope(isolate); |
212 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate); | 213 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate); |
213 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global); | 214 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global); |
214 ASSERT(!context.IsEmpty()); | 215 ASSERT(!context.IsEmpty()); |
215 { | 216 { |
216 v8::Context::Scope scope(context); | 217 v8::Context::Scope scope(context); |
217 Isolate* isolate = Isolate::Current(); | |
218 double baseline_total = 0; | 218 double baseline_total = 0; |
219 for (size_t i = 0; i < fnames.size(); i++) { | 219 for (size_t i = 0; i < fnames.size(); i++) { |
220 TimeDelta time; | 220 TimeDelta time; |
221 time = ProcessFile(fnames[i].c_str(), encoding, isolate, print_tokens, | 221 time = ProcessFile(fnames[i].c_str(), encoding, |
| 222 reinterpret_cast<Isolate*>(isolate), print_tokens, |
222 repeat); | 223 repeat); |
223 baseline_total += time.InMillisecondsF(); | 224 baseline_total += time.InMillisecondsF(); |
224 } | 225 } |
225 if (benchmark.empty()) benchmark = "Baseline"; | 226 if (benchmark.empty()) benchmark = "Baseline"; |
226 printf("%s(RunTime): %.f ms\n", benchmark.c_str(), baseline_total); | 227 printf("%s(RunTime): %.f ms\n", benchmark.c_str(), baseline_total); |
227 } | 228 } |
228 } | 229 } |
229 v8::V8::Dispose(); | 230 v8::V8::Dispose(); |
230 return 0; | 231 return 0; |
231 } | 232 } |
OLD | NEW |