-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUprofilerExample.php
More file actions
131 lines (120 loc) · 3.18 KB
/
UprofilerExample.php
File metadata and controls
131 lines (120 loc) · 3.18 KB
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
<?php
//require 'vendor/autoload.php';
//
//use Aws\DynamoDb\DynamoDbClient;
//
//$client = DynamoDbClient::factory(array(
// 'profile' => 'project1',
// 'version' => 'latest',
// 'region' => 'us-west-2', #replace with your desired region
// 'endpoint' => 'http://localhost:8000'
//));
//
////// Create an "errors" table
////$client->createTable(array(
//// 'TableName' => 'errors',
//// 'AttributeDefinitions' => array(
//// array(
//// 'AttributeName' => 'id',
//// 'AttributeType' => 'N'
//// ),
//// array(
//// 'AttributeName' => 'time',
//// 'AttributeType' => 'N'
//// )
//// ),
//// 'KeySchema' => array(
//// array(
//// 'AttributeName' => 'id',
//// 'KeyType' => 'HASH'
//// ),
//// array(
//// 'AttributeName' => 'time',
//// 'KeyType' => 'RANGE'
//// )
//// ),
//// 'ProvisionedThroughput' => array(
//// 'ReadCapacityUnits' => 10,
//// 'WriteCapacityUnits' => 20
//// )
////));
//
//$result = $client->listTables();
//
//// TableNames contains an array of table names
//foreach ($result['TableNames'] as $tableName) {
// echo $tableName . "\n";
//}
//
//$result = $client->describeTable(array(
// 'TableName' => 'errors'
//));
//
//// The result of an operation can be used like an array
//echo $result['Table']['ItemCount'] . "\n";
////> 0
//
//// Use the getPath() method to retrieve deeply nested array key values
//echo $result->getPath('Table/ProvisionedThroughput/ReadCapacityUnits') . "\n";
////> 15
//
//
//$time = time();
//
//$result = $client->putItem(array(
// 'TableName' => 'errors',
// 'Item' => array(
// 'id' => array('N' => '1201'),
// 'time' => array('N' => $time),
// 'error' => array('S' => 'Executive overflow'),
// 'message' => array('S' => 'no vacant areas')
// )
//));
//
//$result = $client->getItem(array(
// 'ConsistentRead' => true,
// 'TableName' => 'errors',
// 'Key' => array(
// 'id' => array('N' => '1201'),
// 'time' => array('N' => $time)
// )
//));
//
//// Grab value from the result object like an array
//echo $result['Item']['id']['N'] . "\n";
////> 1201
//echo $result->getPath('Item/id/N') . "\n";
////> 1201
//echo $result['Item']['error']['S'] . "\n";
////> Executive overflow
//echo $result['Item']['message']['S'] . "\n";
//
//$uprofiler_ROOT = getcwd(). "/uprofiler";
//include_once $uprofiler_ROOT . "/uprofiler_lib/utils/uprofiler_lib.php";
//include_once $uprofiler_ROOT . "/uprofiler_lib/utils/uprofiler_runs.php";
function bar($x) {
if ($x > 0) {
bar($x - 1);
}
}
function foo() {
for ($idx = 0; $idx < 2; $idx++) {
bar($idx);
$x = strlen("abc");
}
}
// start profiling
//uprofiler_enable();
include(dirname(__FILE__) . "/UprofilerGetSaveRuns.php");
// run program
foo();
// stop profiler
$uprofiler_data = uprofiler_disable();
$uprofiler_runs = new UprofilerGetSaveRuns();
//$uprofiler_runs->deleteTable();
$run_id = $uprofiler_runs->save_run($uprofiler_data, "brand_name");
echo "---------------\n".
"Assuming you have set up the http based UI for \n".
"uprofiler at some address, you can view run at \n".
"http://<uprofiler-ui-address>/index.php?run=$run_id&source=brand_name\n".
"---------------\n";