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
5new BenchmarkSuite('Assign', [1000], [
6  new Benchmark('BasicAssign1', false, false, 0,
7                BasicAssign1, BasicAssign1Setup, BasicAssign1TearDown),
8  new Benchmark('BasicAssign3', false, false, 0,
9                BasicAssign3, BasicAssign3Setup, BasicAssign3TearDown),
10  new Benchmark('BasicAssignNull3', false, false, 0,
11                BasicAssignNull3, BasicAssignNull3Setup,
12                BasicAssignNull3TearDown),
13]);
14
15var object;
16var src1;
17var src2;
18var src3;
19var obj1;
20var obj2;
21
22// ----------------------------------------------------------------------------
23
24function BasicAssign1Setup() {
25  object = {};
26  obj1 = {};
27  obj2 = {};
28  src1 = { id: "6930530530", obj1: obj1, obj2: obj2 };
29}
30
31function BasicAssign1() {
32  Object.assign(object, src1);
33}
34
35function BasicAssign1TearDown() {
36  return object.id === src1.id &&
37         object.obj1 === obj1 &&
38         object.obj2 === obj2;
39}
40
41// ----------------------------------------------------------------------------
42
43function BasicAssign3Setup() {
44  object = {};
45  obj1 = {};
46  obj2 = {};
47  src1 = { id: "6930530530" };
48  src2 = { obj1: obj1 };
49  src3 = { obj2: obj2 };
50}
51
52function BasicAssign3() {
53  Object.assign(object, src1, src2, src3);
54}
55
56function BasicAssign3TearDown() {
57  return object.id === src1.id &&
58         object.obj1 === src2 &&
59         object.obj2 === src3;
60}
61
62// ----------------------------------------------------------------------------
63
64function BasicAssignNull3Setup() {
65  object = {};
66  obj1 = {};
67  obj2 = {};
68  src1 = { id: "6930530530" };
69  src2 = null;
70  src3 = { obj1: obj1, obj2: obj2 };
71}
72
73function BasicAssignNull3() {
74  Object.assign(object, src1, src2, src3);
75}
76
77function BasicAssignNull3TearDown() {
78  return object.id === src1.id &&
79         object.obj1 === src2 &&
80         object.obj2 === src3;
81}
82