Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 new BenchmarkSuite('TemplateLiterals', [1000], [ | |
| 6 new Benchmark('Untagged', false, false, 0, | |
| 7 Untagged, UntaggedSetup, UntaggedTearDown), | |
| 8 new Benchmark('TaggedRaw', false, false, 0, | |
| 9 TaggedRaw, TaggedRawSetup, TaggedRawTearDown), | |
| 10 ]); | |
| 11 | |
| 12 | |
| 13 var result; | |
| 14 var SUBJECT = 'Bob'; | |
| 15 var TARGET = 'Mary'; | |
| 16 var OBJECT = 'apple'; | |
| 17 | |
| 18 function UntaggedSetup() { | |
| 19 result = undefined; | |
| 20 } | |
| 21 | |
| 22 function Untagged() { | |
| 23 result = `${SUBJECT} gives ${TARGET} an ${OBJECT}.`; | |
| 24 } | |
| 25 | |
| 26 function UntaggedTearDown() { | |
| 27 var expected = '' + SUBJECT + ' gives ' + TARGET + ' an ' + OBJECT + '.'; | |
| 28 return result === expected; | |
| 29 } | |
| 30 | |
| 31 | |
| 32 // ---------------------------------------------------------------------------- | |
| 33 | |
| 34 | |
| 35 function TaggedRawSetup() { | |
| 36 result = undefined; | |
| 37 } | |
| 38 | |
| 39 function TaggedRaw() { | |
| 40 result = String.raw `${SUBJECT} gives ${TARGET} an ${OBJECT} \ud83c\udf4f.`; | |
| 41 } | |
| 42 | |
| 43 function TaggedRawTearDown() { | |
| 44 var expected = '' + SUBJECT + ' gives ' + TARGET + ' an ' + OBJECT + ' \\ud83c \\udf4f.'; | |
|
arv (Not doing code reviews)
2014/12/01 20:04:08
long line
| |
| 45 return result === expected; | |
| 46 } | |
| 47 | |
| 48 | |
| 49 // ---------------------------------------------------------------------------- | |
| 50 | |
| 51 | |
| OLD | NEW |