Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: src/lexer/lexer-shell.cc

Issue 71013006: Make checking tokens default in lexer-shell. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Adjust output for --benchmark flag. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 } 206 }
207 } 207 }
208 208
209 209
210 std::pair<TimeDelta, TimeDelta> ProcessFile( 210 std::pair<TimeDelta, TimeDelta> ProcessFile(
211 const char* fname, 211 const char* fname,
212 Encoding encoding, 212 Encoding encoding,
213 Isolate* isolate, 213 Isolate* isolate,
214 bool run_baseline, 214 bool run_baseline,
215 bool run_experimental, 215 bool run_experimental,
216 bool print_tokens) { 216 bool print_tokens,
217 bool check_tokens) {
217 if (print_tokens) { 218 if (print_tokens) {
218 printf("Processing file %s\n", fname); 219 printf("Processing file %s\n", fname);
219 } 220 }
220 HandleScope handle_scope(isolate); 221 HandleScope handle_scope(isolate);
221 std::vector<TokenWithLocation> baseline_tokens, experimental_tokens; 222 std::vector<TokenWithLocation> baseline_tokens, experimental_tokens;
222 TimeDelta baseline_time, experimental_time; 223 TimeDelta baseline_time, experimental_time;
223 if (run_baseline) { 224 if (run_baseline) {
224 baseline_time = RunBaselineScanner( 225 baseline_time = RunBaselineScanner(
225 fname, isolate, encoding, print_tokens, &baseline_tokens); 226 fname, isolate, encoding, print_tokens || check_tokens,
227 &baseline_tokens);
226 } 228 }
227 if (run_experimental) { 229 if (run_experimental) {
228 experimental_time = RunExperimentalScanner( 230 experimental_time = RunExperimentalScanner(
229 fname, isolate, encoding, print_tokens, &experimental_tokens); 231 fname, isolate, encoding, print_tokens || check_tokens,
232 &experimental_tokens);
230 } 233 }
231 if (print_tokens && !run_experimental) { 234 if (print_tokens && !run_experimental) {
232 PrintTokens("Baseline", baseline_tokens); 235 PrintTokens("Baseline", baseline_tokens);
233 } 236 }
234 if (print_tokens && !run_baseline) { 237 if (print_tokens && !run_baseline) {
235 PrintTokens("Experimental", experimental_tokens); 238 PrintTokens("Experimental", experimental_tokens);
236 } 239 }
237 if (print_tokens && run_baseline && run_experimental) { 240 if ((print_tokens || check_tokens) && run_baseline && run_experimental) {
238 printf("No of tokens in Baseline: %d\n", 241 if (print_tokens) {
239 static_cast<int>(baseline_tokens.size())); 242 printf("No of tokens in Baseline: %d\n",
240 printf("No of tokens in Experimental: %d\n", 243 static_cast<int>(baseline_tokens.size()));
241 static_cast<int>(experimental_tokens.size())); 244 printf("No of tokens in Experimental: %d\n",
242 printf("Baseline and Experimental:\n"); 245 static_cast<int>(experimental_tokens.size()));
246 printf("Baseline and Experimental:\n");
247 }
243 for (size_t i = 0; i < experimental_tokens.size(); ++i) { 248 for (size_t i = 0; i < experimental_tokens.size(); ++i) {
244 experimental_tokens[i].Print("=>"); 249 if (print_tokens) experimental_tokens[i].Print("=>");
245 if (experimental_tokens[i] != baseline_tokens[i]) { 250 if (experimental_tokens[i] != baseline_tokens[i]) {
246 printf("MISMATCH:\n"); 251 printf("MISMATCH:\n");
247 baseline_tokens[i].Print("Expected: "); 252 baseline_tokens[i].Print("Expected: ");
248 experimental_tokens[i].Print("Actual: "); 253 experimental_tokens[i].Print("Actual: ");
249 exit(1); 254 exit(1);
250 } 255 }
251 } 256 }
252 } 257 }
253 return std::make_pair(baseline_time, experimental_time); 258 return std::make_pair(baseline_time, experimental_time);
254 } 259 }
255 260
256 261
257 int main(int argc, char* argv[]) { 262 int main(int argc, char* argv[]) {
258 v8::V8::InitializeICU(); 263 v8::V8::InitializeICU();
259 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); 264 v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
260 Encoding encoding = ASCII; 265 Encoding encoding = ASCII;
261 bool print_tokens = false; 266 bool print_tokens = false;
262 bool run_baseline = true; 267 bool run_baseline = true;
263 bool run_experimental = true; 268 bool run_experimental = true;
269 bool no_check = false;
marja 2013/11/13 10:18:31 I tried to make these bools positive instead of ne
264 std::vector<std::string> fnames; 270 std::vector<std::string> fnames;
265 std::string benchmark; 271 std::string benchmark;
266 for (int i = 0; i < argc; ++i) { 272 for (int i = 0; i < argc; ++i) {
267 if (strcmp(argv[i], "--latin1") == 0) { 273 if (strcmp(argv[i], "--latin1") == 0) {
268 encoding = LATIN1; 274 encoding = LATIN1;
269 } else if (strcmp(argv[i], "--utf8") == 0) { 275 } else if (strcmp(argv[i], "--utf8") == 0) {
270 encoding = UTF8; 276 encoding = UTF8;
271 } else if (strcmp(argv[i], "--utf16") == 0) { 277 } else if (strcmp(argv[i], "--utf16") == 0) {
272 encoding = UTF16; 278 encoding = UTF16;
273 } else if (strcmp(argv[i], "--ascii") == 0) { 279 } else if (strcmp(argv[i], "--ascii") == 0) {
274 encoding = ASCII; 280 encoding = ASCII;
275 } else if (strcmp(argv[i], "--print-tokens") == 0) { 281 } else if (strcmp(argv[i], "--print-tokens") == 0) {
276 print_tokens = true; 282 print_tokens = true;
277 } else if (strcmp(argv[i], "--no-baseline") == 0) { 283 } else if (strcmp(argv[i], "--no-baseline") == 0) {
278 run_baseline = false; 284 run_baseline = false;
279 } else if (strcmp(argv[i], "--no-experimental") == 0) { 285 } else if (strcmp(argv[i], "--no-experimental") == 0) {
280 run_experimental = false; 286 run_experimental = false;
287 } else if (strcmp(argv[i], "--no-check") == 0) {
288 no_check = true;
281 } else if (strncmp(argv[i], "--benchmark=", 12) == 0) { 289 } else if (strncmp(argv[i], "--benchmark=", 12) == 0) {
282 benchmark = std::string(argv[i]).substr(12); 290 benchmark = std::string(argv[i]).substr(12);
283 } else if (i > 0 && argv[i][0] != '-') { 291 } else if (i > 0 && argv[i][0] != '-') {
284 fnames.push_back(std::string(argv[i])); 292 fnames.push_back(std::string(argv[i]));
285 } 293 }
286 } 294 }
287 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 295 v8::Isolate* isolate = v8::Isolate::GetCurrent();
288 { 296 {
289 v8::HandleScope handle_scope(isolate); 297 v8::HandleScope handle_scope(isolate);
290 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(); 298 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
291 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global); 299 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
292 ASSERT(!context.IsEmpty()); 300 ASSERT(!context.IsEmpty());
293 { 301 {
294 v8::Context::Scope scope(context); 302 v8::Context::Scope scope(context);
295 Isolate* isolate = Isolate::Current(); 303 Isolate* isolate = Isolate::Current();
296 double baseline_total = 0, experimental_total = 0; 304 double baseline_total = 0, experimental_total = 0;
297 for (size_t i = 0; i < fnames.size(); i++) { 305 for (size_t i = 0; i < fnames.size(); i++) {
298 std::pair<TimeDelta, TimeDelta> times; 306 std::pair<TimeDelta, TimeDelta> times;
299 times = ProcessFile(fnames[i].c_str(), encoding, isolate, 307 bool check_tokens = run_baseline && run_experimental && !no_check;
300 run_baseline, run_experimental, print_tokens); 308 times = ProcessFile(fnames[i].c_str(), encoding, isolate, run_baseline,
309 run_experimental, print_tokens, check_tokens);
301 baseline_total += times.first.InMillisecondsF(); 310 baseline_total += times.first.InMillisecondsF();
302 experimental_total += times.second.InMillisecondsF(); 311 experimental_total += times.second.InMillisecondsF();
303 } 312 }
304 if (run_baseline) { 313 if (run_baseline) {
305 printf("Baseline%s(RunTime): %.f ms\n", benchmark.c_str(), 314 printf("Baseline%s(RunTime): %.f ms\n", benchmark.c_str(),
306 baseline_total); 315 baseline_total);
307 } 316 }
308 if (run_experimental) { 317 if (run_experimental) {
309 printf("Experimental%s(RunTime): %.f ms\n", benchmark.c_str(), 318 if (benchmark.empty()) benchmark = "Experimental";
319 printf("%s(RunTime): %.f ms\n", benchmark.c_str(),
310 experimental_total); 320 experimental_total);
311 } 321 }
312 } 322 }
313 } 323 }
314 v8::V8::Dispose(); 324 v8::V8::Dispose();
315 return 0; 325 return 0;
316 } 326 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698