Chromium Code Reviews| Index: test/js-perf-test/Templates/harmony-templates.js |
| diff --git a/test/js-perf-test/Templates/harmony-templates.js b/test/js-perf-test/Templates/harmony-templates.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..533f9d408a305095c1bd89405ac9fc84aedd5efb |
| --- /dev/null |
| +++ b/test/js-perf-test/Templates/harmony-templates.js |
| @@ -0,0 +1,51 @@ |
| +// Copyright 2014 the V8 project authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +new BenchmarkSuite('TemplateLiterals', [1000], [ |
| + new Benchmark('Untagged', false, false, 0, |
| + Untagged, UntaggedSetup, UntaggedTearDown), |
| + new Benchmark('TaggedRaw', false, false, 0, |
| + TaggedRaw, TaggedRawSetup, TaggedRawTearDown), |
| +]); |
| + |
| + |
| +var result; |
| +var SUBJECT = 'Bob'; |
| +var TARGET = 'Mary'; |
| +var OBJECT = 'apple'; |
| + |
| +function UntaggedSetup() { |
| + result = undefined; |
| +} |
| + |
| +function Untagged() { |
| + result = `${SUBJECT} gives ${TARGET} an ${OBJECT}.`; |
| +} |
| + |
| +function UntaggedTearDown() { |
| + var expected = '' + SUBJECT + ' gives ' + TARGET + ' an ' + OBJECT + '.'; |
| + return result === expected; |
| +} |
| + |
| + |
| +// ---------------------------------------------------------------------------- |
| + |
| + |
| +function TaggedRawSetup() { |
| + result = undefined; |
| +} |
| + |
| +function TaggedRaw() { |
| + result = String.raw `${SUBJECT} gives ${TARGET} an ${OBJECT} \ud83c\udf4f.`; |
| +} |
| + |
| +function TaggedRawTearDown() { |
| + var expected = '' + SUBJECT + ' gives ' + TARGET + ' an ' + OBJECT + ' \\ud83c\\udf4f.'; |
|
arv (Not doing code reviews)
2014/12/01 20:04:08
long line
|
| + return result === expected; |
| +} |
| + |
| + |
| +// ---------------------------------------------------------------------------- |
| + |
| + |