Skip to content

Commit 5a24022

Browse files
authored
Merge pull request #2 from na2axl/implementing_link
link system added
2 parents c7d5897 + 80162e2 commit 5a24022

File tree

10 files changed

+306
-121
lines changed

10 files changed

+306
-121
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "na2axl/jsondb",
3-
"description": "Manage local databases with JSON files and JSONDB Query Language (JQL).",
3+
"description": "Manage JSON files as databases with JSON Query Language (JQL).",
44
"keywords": ["database", "file", "json", "nosql", "db"],
55
"homepage": "https://github.com/na2axl/jsondb-php",
66
"type": "library",

src/JSONDB/Benchmark.php

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* JSONDB - JSON Database Manager
55
*
6-
* Manage local databases with JSON files and JSON Query Language (JQL)
6+
* Manage JSON files as databases with JSON Query Language (JQL)
77
*
88
* This content is released under the MIT License (MIT)
99
*
@@ -59,7 +59,8 @@ class Benchmark {
5959
* @return void
6060
*/
6161
public function mark( $name ) {
62-
self::$marker[$name] = microtime( ) ;
62+
self::$marker[$name]['e'] = microtime( ) ;
63+
self::$marker[$name]['m'] = memory_get_usage( ) ;
6364
}
6465

6566
/**
@@ -73,24 +74,41 @@ public function elapsed_time( $point1 = '', $point2 = '', $decimals = 4 ) {
7374
if ( $point1 === '' ) {
7475
return '{elapsed_time}' ;
7576
}
76-
if ( !array_key_exists( $point1, self::$marker )) {
77+
if ( !array_key_exists( $point1, self::$marker ) ) {
7778
return '' ;
7879
}
79-
if ( !array_key_exists( $point2, self::$marker )) {
80-
self::$marker[$point2] = microtime( ) ;
80+
if ( !array_key_exists( $point2, self::$marker ) ) {
81+
self::$marker[$point2]['e'] = microtime( ) ;
82+
self::$marker[$point2]['m'] = memory_get_usage( ) ;
8183
}
82-
list( $sm, $ss ) = explode( ' ', self::$marker[$point1] ) ;
83-
list( $em, $es ) = explode( ' ', self::$marker[$point2] ) ;
84+
list( $sm, $ss ) = explode( ' ', self::$marker[$point1]['e'] ) ;
85+
list( $em, $es ) = explode( ' ', self::$marker[$point2]['e'] ) ;
8486

8587
return number_format( ( $em + $es ) - ( $sm + $ss ), $decimals ) ;
8688
}
8789

8890
/**
8991
* Calculate the memory usage of a benchmark point
90-
* @return int
92+
* @param string $point1 The name of the first benchmark point
93+
* @param string $point2 The name of the second benchmark point
94+
* @param int $decimals
95+
* @return mixed
9196
*/
92-
public function memory_usage( ) {
93-
return memory_get_usage();
97+
public function memory_usage( $point1 = '', $point2 = '', $decimals = 4 ) {
98+
if ( $point1 === '' ) {
99+
return '{memory_usage}' ;
100+
}
101+
if ( !array_key_exists( $point1, self::$marker ) ) {
102+
return '' ;
103+
}
104+
if ( !array_key_exists( $point2, self::$marker ) ) {
105+
self::$marker[$point2]['e'] = microtime( ) ;
106+
self::$marker[$point2]['m'] = memory_get_usage( ) ;
107+
}
108+
$sm = self::$marker[$point1]['m'] ;
109+
$em = self::$marker[$point2]['m'] ;
110+
111+
return number_format( $em - $sm , $decimals ) ;
94112
}
95113

96114
}

src/JSONDB/Cache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* JSONDB - JSON Database Manager
55
*
6-
* Manage local databases with JSON files and JSON Query Language (JQL)
6+
* Manage JSON files as databases with JSON Query Language (JQL)
77
*
88
* This content is released under the MIT License (MIT)
99
*

src/JSONDB/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* JSONDB - JSON Database Manager
55
*
6-
* Manage local databases with JSON files and JSON Query Language (JQL)
6+
* Manage JSON files as databases with JSON Query Language (JQL)
77
*
88
* This content is released under the MIT License (MIT)
99
*

src/JSONDB/Exception.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* JSONDB - JSON Database Manager
55
*
6-
* Manage local databases with JSON files and JSON Query Language (JQL)
6+
* Manage JSON files as databases with JSON Query Language (JQL)
77
*
88
* This content is released under the MIT License (MIT)
99
*

0 commit comments

Comments
 (0)