Script Preparation code:
AخA
 
var testString = '{ "type": "Feature", "properties": { "OBJECTID": 1, "OBJECTID_12": 1, "ELEV_IN_FT": 5397, "DATE_CREATED": "318816000000", "DATE_EDITED": "", "name": "Agua Sal Creek", "type": "Stream", "source": "USGS_PlaceNamesUSA", "description": "", "state": "Arizona", "class": "Place Name", "map_layer": "Place Name", "state_ab": "AZ", "lat": 36.461112200202791, "long": -109.47843940044683, "gmu_id": "", "hasname": "" }, "geometry": { "type": "Point", "coordinates": [ -109.478439400446817, 36.461112200202805, 0.0 ] } },\n{ "type": "Feature", "properties": { "OBJECTID": 1, "OBJECTID_12": 1, "ELEV_IN_FT": 5397, "DATE_CREATED": "318816000000", "DATE_EDITED": "", "name": "Agua Sal Creek", "type": "Stream", "source": "USGS_PlaceNamesUSA", "description": "", "state": "Arizona", "class": "Place Name", "map_layer": "Place Name", "state_ab": "AZ", "lat": 36.461112200202791, "long": -109.47843940044683, "gmu_id": "", "hasname": "" }, "geometry": { "type": "Point", "coordinates": [ -109.478439400446817, 36.461112200202805, 0.0 ] } },\n{ "type": "Feature", "properties": { "OBJECTID": 1, "OBJECTID_12": 1, "ELEV_IN_FT": 5397, "DATE_CREATED": "318816000000", "DATE_EDITED": "", "name": "Agua Sal Creek", "type": "Stream", "source": "USGS_PlaceNamesUSA", "description": "", "state": "Arizona", "class": "Place Name", "map_layer": "Place Name", "state_ab": "AZ", "lat": 36.461112200202791, "long": -109.47843940044683, "gmu_id": "", "hasname": "" }, "geometry": { "type": "Point", "coordinates": [ -109.478439400446817, 36.461112200202805, 0.0 ] } },\n{ "type": "Feature", "properties": { "OBJECTID": 1, "OBJECTID_12": 1, "ELEV_IN_FT": 5397, "DATE_CREATED": "318816000000", "DATE_EDITED": "", "name": "Agua Sal Creek", "type": "Stream", "source": "USGS_PlaceNamesUSA", "description": "", "state": "Arizona", "class": "Place Name", "map_layer": "Place Name", "state_ab": "AZ", "lat": 36.461112200202791, "long": -109.47843940044683, "gmu_id": "", "hasname": "" }, "geometry": { "type": "Point", "coordinates": [ -109.478439400446817, 36.461112200202805, 0.0 ] } },\n'
Tests:
  • Splitting

     
    var values = testString.split("\n");
    var output = ''
    for (let v of values) {
      if (v[v.length-1] === ',') output += v.substring(0, v.length-1)+'\n'
    }
  • Regex

    x
     
    var output = testString.replace(',\n', '\n')
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Splitting
    Regex

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 5 months ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Chrome 131 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Splitting 4527420.5 Ops/sec
Regex 3983167.5 Ops/sec