<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
var elements = [8,9,34,12,4,2,1,5,7,2,8,1,25,7,1,2,3,1,2,4,2,3,5,3,9,34,12,4,2,1,5,7,2,8,1,25,7,1,2,3,1,2,4,2,39,34,12,4,2,1,5,7,2,8,1,25,7,1,2,3,1,2,4,2,39,34,12,4,2,1,5,7,2,8,1,25,7,1,2,3,1,2,4,2,39,34,12,4,2,1,5,7,2,8,1,25,7,1,2,3,1,2,4,2,39,34,12,4,2,1,5,7,2,8,1,25,7,1,2,3,1,2,4,2,39,34,12,4,2,1,5,7,2,8,1,25,7,1,2,3,1,2,4,2,3,7,2,8,1,25,7,1,2,3,1,2,4,2,37,2,8,1,25,7,1,2,3,1,2,4,2,37,2,8,1,25,7,1,2,3,1,2,4,2,37,2,8,1,25,7,1,2,3,1,2,4,2,3,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,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2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1]
_.uniq(elements)
[new Set(elements)]
elements.filter((v, i, a) => a.indexOf(v) === i)
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
_.uniq | |
set | |
uniq by filter |
Test name | Executions per second |
---|---|
_.uniq | 61039.0 Ops/sec |
set | 61784.0 Ops/sec |
uniq by filter | 20224.8 Ops/sec |
The task is to extract and format benchmark results from a large JSON object.
Here's the extracted data:
Benchmark Results
Test Name | Execution Time (ms) |
---|---|
set | 1.20 |
_.uniq | 0.33 |
uniq by filter | 12.56 |
Original Data
{
"test": [
{
"Benchmark Definition": "_.uniq(elements)",
"Test Name": "_.uniq"
},
{
"Benchmark Definition": "[...new Set(elements)]",
"Test Name": "set"
},
{
"Benchmark Definition": "elements.filter((v, i, a) => a.indexOf(v) === i)",
"Test Name": "uniq by filter"
}
],
"Html Preparation Code": "<script type=\"text/javascript\" src=\"https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js\"></script>",
"Individual test cases": [
{
"Benchmark Definition": "_.uniq(elements)",
"Test Name": "_.uniq"
},
{
"Benchmark Definition": "[...new Set(elements)]",
"Test Name": "set"
},
{
"Benchmark Definition": "elements.filter((v, i, a) => a.indexOf(v) === i)",
"Test Name": "uniq by filter"
}
],
"Latest benchmark result": [
{
"RawUAString": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36",
"Browser": "Chrome 91",
"DevicePlatform": "Desktop",
"OperatingSystem": "Linux",
"ExecutionsPerSecond": 61784.0,
"TestName": "set"
},
{
"RawUAString": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36",
"Browser": "Chrome 91",
"DevicePlatform": "Desktop",
"OperatingSystem": "Linux",
"ExecutionsPerSecond": 61038.98828125,
"TestName": "_.uniq"
},
{
"RawUAString": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36",
"Browser": "Chrome 91",
"DevicePlatform": "Desktop",
"OperatingSystem": "Linux",
"ExecutionsPerSecond": 20224.80078125,
"TestName": "uniq by filter"
}
]
}
The extracted data is in a format suitable for displaying benchmark results, with the test names and execution times formatted nicely.