User Tools

Site Tools


json:benchmark

JSON Data Benchmark Testing

PHP Stopwatch

Stopwatch plugin measures execution time of PHP code:

  • <stopwatch reset> - Resets stopwatch to zero.
  • <stopwatch show> - Show elapsed time in seconds since last reset.

Recursive JSON load

Here is JSON data with src attribute, which links to itself. So it is recursively loaded 30 times.

<stopwatch reset>
<json id=cookie path=cookie src=benchmark#cookie display=combined,log*>
{
  "name": "Butter cookie",
  "type": "cookie",
  "Ingredients": {
    "eggs": "3",
    "flour": "500 g",
    "sugar": "300 g",
    "butter": "250 g"
  }
}
</json>
Time elapsed: <stopwatch show>
{
    "name": "Butter cookie",
    "type": "cookie",
    "Ingredients": {
        "eggs": "3",
        "flour": "500 g",
        "sugar": "300 g",
        "butter": "250 g"
    }
}
  • element: json, id: cookie, path: cookie, inline data, external data (from path: )
    • internal file: benchmark, ERROR: file not found

Time elapsed: 0.003

Load multiple files into JSON array

Here is one long JSON file with random data: file1. For testing purposes it should be copied to different filenames 1000 times. Here is bash command for this:

for i in {2..1000}; do cp file1.txt "file$i.txt"; done

Load one file

null
  • element: json, path: stack1[], external data (from path: )

<json path=stack1[] src=.1000files:file1 display=combined,log*></json>
Time elapsed: 0.000

Load 112 files

null
  • element: json, path: stack2[], external data (from path: )

<json path=stack2[] src=.1000files:file1* display=combined,log*></json>
Time elapsed: 0.000

Load 1000 files

  • element: json, path: stack3[], external data (from path: )

<json path=stack3[] src=.1000files:file*></json>
Time elapsed: 0.000

Single item

%$stack2.55.0.friends.0.name%
(null)
Time elapsed: 0.001

Table of 112 files

%$stack2[]{"Name0":0.friends.0.name, "Name1":1.friends.0.name, "Name2":2.friends.0.name, "Name3":3.friends.0.name, "Name4":4.friends.0.name, "Name5":5.friends.0.name, "Name6":6.friends.0.name, "Name7":7.friends.0.name, "Name8":8.friends.0.name}%

Name0Name1Name2Name3Name4Name5Name6Name7Name8
(null)(null)(null)(null)(null)(null)(null)(null)(null)

Time elapsed: 0.000

Table of 1000 files

%$stack3[]{ ... }%

Name0Name1Name2Name3Name4Name5Name6Name7Name8
(null)(null)(null)(null)(null)(null)(null)(null)(null)

Time elapsed: 0.000

Show JSON data of 112 files

This is most time consuming:

%$stack2 #code#%

null
Time elapsed: 0.000

json/benchmark.txt · Last modified: 2023/10/26 22:34 by admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki