Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
Merge pull request perftools#326 from perftools/drop-superfluous-fiel…
Browse files Browse the repository at this point in the history
…ds-v2
  • Loading branch information
glensc authored Sep 15, 2020
2 parents 9986b00 + cfc5003 commit 3f7eb16
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 33 deletions.
20 changes: 7 additions & 13 deletions src/Xhgui/Saver/Mongo.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,20 @@ public function __construct(MongoCollection $collection)

public function save(array $data)
{
if (isset($data['meta']['request_ts'])) {
$data['meta']['request_ts'] = new MongoDate($data['meta']['request_ts']['sec']);
}

if (isset($data['meta']['request_ts_micro'])) {
$data['meta']['request_ts_micro'] = new MongoDate(
$data['meta']['request_ts_micro']['sec'],
$data['meta']['request_ts_micro']['usec']
);
}
// build 'request_ts' and 'request_date' from 'request_ts_micro'
$ts = $data['meta']['request_ts_micro'];
$sec = $ts['sec'];
$usec = $ts['usec'];

$meta = [
'url' => $data['meta']['url'],
'get' => $data['meta']['get'],
'env' => $data['meta']['env'],
'SERVER' => $data['meta']['SERVER'],
'simple_url' => $data['meta']['simple_url'],
'request_ts' => $data['meta']['request_ts'],
'request_ts_micro' => $data['meta']['request_ts_micro'],
'request_date' => $data['meta']['request_date'],
'request_ts' => new MongoDate($sec),
'request_ts_micro' => new MongoDate($sec, $usec),
'request_date' => date('Y-m-d', $sec),
];

$a = [
Expand Down
11 changes: 8 additions & 3 deletions src/Xhgui/Saver/Pdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ public function save(array $data)
{
$main = $data['profile']['main()'];

// build 'request_ts' and 'request_date' from 'request_ts_micro'
$ts = $data['meta']['request_ts_micro'];
$sec = $ts['sec'];
$usec = $ts['usec'];

$this->stmt->execute(array(
'id' => Xhgui_Util::generateId(),
'profile' => json_encode($data['profile']),
Expand All @@ -90,9 +95,9 @@ public function save(array $data)
'GET' => json_encode($data['meta']['get']),
'ENV' => json_encode($data['meta']['env']),
'simple_url' => $data['meta']['simple_url'],
'request_ts' => $data['meta']['request_ts']['sec'],
'request_ts_micro' => "{$data['meta']['request_ts_micro']['sec']}.{$data['meta']['request_ts_micro']['usec']}",
'request_date' => $data['meta']['request_date'],
'request_ts' => $sec,
'request_ts_micro' => "$sec.$usec",
'request_date' => date('Y-m-d', $sec),
'main_wt' => $main['wt'],
'main_ct' => $main['ct'],
'main_cpu' => $main['cpu'],
Expand Down
2 changes: 0 additions & 2 deletions tests/Controller/ImportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public function testImportSuccess()
'get' => [],
'env' => [],
'SERVER' => ['REQUEST_TIME' => 1358787612],
'request_date' => '2013-01-21',
'request_ts' => ['sec' => 1358787612, 'usec' => 0],
'request_ts_micro' => ['sec' => 1358787612, 'usec' => 123456]
],
'profile' => [
Expand Down
20 changes: 5 additions & 15 deletions tests/fixtures/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
"get": [],
"env": [],
"SERVER": {"REQUEST_TIME": 1358787612},
"request_ts": {"sec": 1358787612, "usec": 0},
"request_ts_micro": {"sec": 1358787612, "usec": 123456},
"request_date": "2013-01-21"
"request_ts_micro": {"sec": 1358787612, "usec": 123456}
},
"profile": {
"main()==>strpos()": {
Expand All @@ -36,9 +34,7 @@
"get": [],
"env": [],
"SERVER": {"REQUEST_TIME": 1358701212},
"request_ts": {"sec": 1358701212, "usec": 0},
"request_ts_micro": {"sec": 1358701212, "usec": 123456},
"request_date": "2013-01-20"
"request_ts_micro": {"sec": 1358701212, "usec": 123456}
},
"profile": {
"main()": {
Expand Down Expand Up @@ -100,9 +96,7 @@
"get": [],
"env": [],
"SERVER": {"REQUEST_TIME": 1358614812},
"request_ts": {"sec": 1358614812, "usec": 0},
"request_ts_micro": {"sec": 1358614812, "usec": 123456},
"request_date": "2013-01-19"
"request_ts_micro": {"sec": 1358614812, "usec": 123456}
},
"profile": {
"main()": {
Expand Down Expand Up @@ -157,9 +151,7 @@
"get": [],
"env": [],
"SERVER": {"REQUEST_TIME": 1358528412},
"request_ts": {"sec": 1358528412, "usec": 0},
"request_ts_micro": {"sec": 1358528412, "usec": 123456},
"request_date": "2013-01-18"
"request_ts_micro": {"sec": 1358528412, "usec": 123456}
},
"profile": {
"main()": {
Expand Down Expand Up @@ -193,9 +185,7 @@
"get": [],
"env": [],
"SERVER": {"REQUEST_TIME": 1358614812},
"request_ts": {"sec": 1358614812, "usec": 0},
"request_ts_micro": {"sec": 1358614812, "usec": 123456},
"request_date": "2013-01-19"
"request_ts_micro": {"sec": 1358614812, "usec": 123456}
},
"profile": {
"main()": {
Expand Down

0 comments on commit 3f7eb16

Please sign in to comment.