This repository has been archived by the owner on Aug 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
dictionary.php
146 lines (130 loc) · 4.13 KB
/
dictionary.php
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
/**
* PHP PGO Training - to be used during Profile Guided Optimization builds.
*
* Copyright (C) 2016 Intel Corporation
*
* This program is free software and open source software; you can redistribute
* it and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
* http://www.gnu.org/licenses/gpl.html
*
* Authors:
* Gabriel Samoila <gabriel.c.samoila@intel.com>
* Bogdan Andone <bogdan.andone@intel.com>
*/
/* Constants for scaling the number of runs;
* Users can change these value for tuning execution weights
*/
define('KEYS_SIZE', 50); /* number of keys pregenerated in keys.php */
define('DICTIONARY_IT', 300000); /* number of hash-map iterations */
define('ARRAY_KEYS_IT', 20000); /* # of array_keys() calls */
function hash_register_training(& $functions)
{
echo "Hash benchmark module loaded!\n";
$functions[] = "run_hash";
}
function run_hash()
{
fill_dictionary(DICTIONARY_IT);
}
$KEYS = array("q0################",
"q1#################",
"q2##################",
"q3###################",
"q4####################",
"q5#####################",
"q6######################",
"q7#######################",
"q8########################",
"q9#########################",
"q10##########################",
"q11###########################",
"q12############################",
"q13#############################",
"q14##############################",
"q15###############################",
"q16################################",
"q17#################################",
"q18##################################",
"q19###################################",
"q20####################################",
"q21#####################################",
"q22######################################",
"q23#######################################",
"q24########################################",
"q25#########################################",
"q26##########################################",
"q27###########################################",
"q28############################################",
"q29#############################################",
"q30##############################################",
"q31###############################################",
"q32################",
"q33#################",
"q34##################",
"q35###################",
"q36####################",
"q37#####################",
"q38######################",
"q39#######################",
"q40########################",
"q41#########################",
"q42##########################",
"q43###########################",
"q44############################",
"q45#############################",
"q46##############################",
"q47###############################",
"q48################################",
"q49#################################");
$dictionary = array();
$references = array();
function add_entry($name, $value) {
if (isset($references[$name])) {
$references[$name]++;
}
else {
$references[$name] = 1;
}
$dictionary[$name] = $value;
//count($dictionary);
}
function get_array_keys() {
return array_keys($GLOBALS['dictionary']);
}
function get_array_values() {
return array_values($GLOBALS['dictionary']);
}
function fill_dictionary($size) {
if (!extension_loaded("hash")) {
echo "Hash is missing!\n";
return -1;
}
$IT = $size / KEYS_SIZE;
$KEYS = $GLOBALS["KEYS"];
for($j=0; $j < $IT; $j++)
for ($i = 0; $i < KEYS_SIZE; $i++) {
$name = 'KEYS';
add_entry($KEYS[$i], $i);
$new = $$name[$i];
$new = null;
}
for ($i = 0; $i < ARRAY_KEYS_IT; $i++) {
$keys = get_array_keys();
}
for ($i = 0; $i < ARRAY_KEYS_IT; $i++) {
$keys = get_array_values();
}
}
?>