var stringsearch = "o", str = "this is foo bar";
str2buffer = function(s){ var bu = new ArrayBuffer(s.length), aUint8 = new Uint8Array(bu );
for(var i=0; i<bu.byteLength; aUint8[i]=s.charCodeAt(i),i++);return aUint8;
};
var bstr = str2buffer ("this is foo bar")
,schar = 'o'.charCodeAt()
,cnt=0;
var ubstr = "this is foo bar".split('').map( function(e,i){ return e.charCodeAt();} )
,schar = 'o'.charCodeAt()
,cnt=0;
var hist = {};
var len = str.length;
function countChar (char, search) {
let num = 0;
let str = search;
let pos = str.indexOf(char);
while(pos > -1) {
str = str.slice(pos + 1);
pos = str.indexOf(char);
num++;
}
return num;
}
function countChar2 (char, str) {
let num = 0;
let pos = str.indexOf(char);
while(pos > -1) {
pos = str.indexOf(char, pos + 1);
num++;
}
return num;
}
("this is foo bar".match(/o/g)||[]).length;
"this is foo bar".split("o").length-1;
for(var count=-1,index=-2; index != -1; count++,index=str.indexOf(stringsearch,index+1));
for(var i=count=0; i<str.length; count+=+(stringsearch===str[i++]));
str.split('').map( function(e,i){ if(e === 'o') return i;} ).filter(Boolean).length;
str.length - str.replace(/o/g,'').length;
for(var i=0;i<bstr.byteLength;schar!==bstr[i++]||cnt++);
for(var i=0;i<ubstr.length;schar!==ubstr[i++]||cnt++);
str.split('').reduce(function(p,c,i,a){ if(c === schar || p === schar){return isNaN(parseInt(p))? 1:+p+1;} return p;})
for (si in str) {
hist[str[si]] = hist[str[si]] ? 1+hist[str[si]]:1;
}
[str].filter(l => l === 'o').length;
for (let charIndex = 0; charIndex < len; ++charIndex) {
if (str[charIndex] === ',') {
count++;
}
}
for (const char of str) {
if (char === 'o') {
count++;
}
}
countChar(stringsearch, str);
countChar2(stringsearch, str);
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
Match | |
Split | |
For loop - access with count | |
For loop - searching for a single character | |
element mapping and filtering with position | |
deleting the character out of the string and measuring the distance in length | |
based on typed arrays access with cnt | |
based on untyped Arrays access with cnt | |
Using reduce | |
Histogram dict | |
split filtering with destructor | |
Sanity check for loop | |
Sanity check for loop with of | |
For loop indexOf slicing | |
For loop indexOf from position |
Test name | Executions per second |
---|---|
Match | 16062125.0 Ops/sec |
Split | 14865070.0 Ops/sec |
For loop - access with count | 2858150.5 Ops/sec |
For loop - searching for a single character | 172816.8 Ops/sec |
element mapping and filtering with position | 2246621.0 Ops/sec |
deleting the character out of the string and measuring the distance in length | 5605556.0 Ops/sec |
based on typed arrays access with cnt | 349560.8 Ops/sec |
based on untyped Arrays access with cnt | 365906.3 Ops/sec |
Using reduce | 605461.7 Ops/sec |
Histogram dict | 72845.0 Ops/sec |
split filtering with destructor | 5634831.0 Ops/sec |
Sanity check for loop | 604556.2 Ops/sec |
Sanity check for loop with of | 1738920.4 Ops/sec |
For loop indexOf slicing | 5107123.5 Ops/sec |
For loop indexOf from position | 5594127.0 Ops/sec |
It looks like you're sharing an example of a JSON string that appears to be a log file or a dataset related to browser performance and benchmarking tests.
If I had to take a wild guess, it seems like this data might be used to analyze the performance of various programming languages or JavaScript engines in different browsers. The "ExecutionsPerSecond" values likely represent the execution rate of each test on each browser version.
Is there something specific you'd like help with regarding this data?