File: CompositeClone_bench.C

package info (click to toggle)
ball 1.5.0%2Bgit20180813.37fc53c-11.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 239,928 kB
  • sloc: cpp: 326,149; ansic: 4,208; python: 2,303; yacc: 1,778; lex: 1,099; xml: 958; sh: 322; javascript: 164; makefile: 88
file content (121 lines) | stat: -rw-r--r-- 2,129 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id: CompositeClone_bench.C,v 1.4 2002/12/18 16:00:32 sturm Exp $
#include <BALL/CONCEPT/benchmark.h>

///////////////////////////

#include <BALL/CONCEPT/composite.h>

///////////////////////////

using namespace BALL;

START_BENCHMARK(CompositeClone, 1.0, "$Id: CompositeClone_bench.C,v 1.4 2002/12/18 16:00:32 sturm Exp $")

/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////

Composite S;
Composite* M = new Composite;
S.appendChild(*M);
for (Position i = 0; i < 200; i++)
{
	M->appendChild(*new Composite);
}



START_SECTION(Cloning, 0.5)

	for (int count = 0; count < 500; count++)
	{
		Composite S2;
		START_TIMER
			S2 = *static_cast<Composite*>(S.create(true));
		STOP_TIMER
		S2.clear();
	}

END_SECTION

START_SECTION(Creation, 0.5)

	for (int count = 0; count < 500; count++)
	{
		for (int i = 0; i < 2000; i++)
		{
			START_TIMER
			Composite* a = new Composite;
			STOP_TIMER
			delete a;
		}
	}
END_SECTION

START_SECTION(Assignment, 0.5)

	for (int count = 0; count < 500; count++)
	{
		Composite atom;
		for (int i = 0; i < 2000; i++)
		{
			Composite* a = new Composite;
			START_TIMER
				*a = atom;
			STOP_TIMER
			delete a;
		}
	}
END_SECTION

START_SECTION(Cloning (create), 0.5)

	for (int count = 0; count < 500; count++)
	{
		Composite atom;
		for (int i = 0; i < 2000; i++)
		{
			Composite* a;
			START_TIMER
				a = (Composite*)atom.create();
			STOP_TIMER
			delete a;
		}
	}
END_SECTION

START_SECTION(Insertion, 0.5)

	for (int count = 0; count < 500; count++)
	{
		for (int i = 0; i < 2000; i++)
		{
			Composite M;
			Composite* a = new Composite;
			START_TIMER
				M.appendChild(*a);
			STOP_TIMER
		}
	}

END_SECTION

START_SECTION(Deleting, 0.5)

	for (int count = 0; count < 500; count++)
	{
		Composite S2;
		S2 = *static_cast<Composite*>(S.create(true));
		START_TIMER
			S2.destroy();
		STOP_TIMER
	}

END_SECTION

/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////

END_BENCHMARK