@balena/odata-parser
Advanced tools
Comparing version 3.0.3-build-fisehara-decode-uri-before-parsing-ed0c07b0a84c9f732f4d655283d4276a95196448-1 to 3.0.3-build-fisehara-optimize-using-global-initialization-94899b779fb879540f3675c3c9d7ca3f9d8af4bf-1
@@ -10,3 +10,3 @@ # Change Log | ||
* Decode escaped URI [fisehara] | ||
* Optimize by moving constant values into global init [fisehara] | ||
@@ -13,0 +13,0 @@ # v3.0.2 |
{ | ||
"name": "@balena/odata-parser", | ||
"version": "3.0.3-build-fisehara-decode-uri-before-parsing-ed0c07b0a84c9f732f4d655283d4276a95196448-1", | ||
"version": "3.0.3-build-fisehara-optimize-using-global-initialization-94899b779fb879540f3675c3c9d7ca3f9d8af4bf-1", | ||
"description": "An OData parser written in OMeta", | ||
@@ -42,4 +42,4 @@ "main": "odata-parser.js", | ||
"versionist": { | ||
"publishedAt": "2024-01-04T12:17:36.168Z" | ||
"publishedAt": "2024-01-04T12:29:35.599Z" | ||
} | ||
} |
@@ -11,7 +11,2 @@ import test from './test'; | ||
test('foo=hello%2520world', (result) => | ||
it('should equal hello%20world with encoded %20 and only decoded once', () => { | ||
assert.equal(result.options.foo, 'hello%20world'); | ||
})); | ||
test.raw('/some%20thing?foo=hello%20world', (result) => | ||
@@ -22,11 +17,2 @@ it('should fail as we do not allow spaces in resource names', () => { | ||
); | ||
test(`$filter=name+eq+'s%C3%BC%C3%9F'`, ['süß'], function (result, err) { | ||
if (err) { | ||
throw err; | ||
} | ||
it('A filter should be present', () => | ||
assert.notEqual(result.options.$filter, null)); | ||
}); | ||
}); |
import test from './test'; | ||
import * as assert from 'assert'; | ||
import * as _ from 'lodash'; | ||
import * as ODataParser from '../odata-parser'; | ||
function measureExecutionTime(runs, uri) { | ||
const startTime = Date.now(); | ||
for (let i = 0; i < runs; i++) { | ||
ODataParser.parse(uri); | ||
} | ||
const endTime = Date.now(); | ||
const diff = endTime - startTime; | ||
const perRun = diff / runs; | ||
console.log( | ||
`\turi.length: ${uri.length}\truns: ${runs}\tperRun: ${JSON.stringify( | ||
perRun, | ||
null, | ||
2, | ||
)}`, | ||
); | ||
return perRun; | ||
} | ||
const selects = []; | ||
for ( | ||
let randomSelectCounter = 0; | ||
randomSelectCounter < 100; | ||
randomSelectCounter++ | ||
) { | ||
selects.push(`long_field_name__field_${randomSelectCounter}`); | ||
} | ||
const $select = '$select=' + selects.join(','); | ||
const $filter = `$filter=(long_field_name__field%20eq%20%27value%27)%20and%20(long_field_name__field_1%20eq%20true)`; | ||
const $nestedExpand = `$expand=resource_test(${$select})`; | ||
const $expand = `$expand=resource_test(${$select};${$nestedExpand};${$filter})`; | ||
const longTestURI = `/resource?${$select}&${$filter}&${$expand}`; | ||
const runCount = 1000; | ||
describe('Stress Testing', function () { | ||
@@ -48,13 +13,2 @@ const ids = _.range(1, 2000); | ||
}); | ||
it(`should parse long (${longTestURI.length} chars) URI ${runCount} times and record average execution time`, () => { | ||
const perRun = measureExecutionTime(runCount, longTestURI); | ||
assert.equal(perRun < 1.5, true); | ||
}); | ||
const shortTestURI = `/resource(123456789)`; | ||
it(`should parse short (${shortTestURI.length} chars) URI ${runCount} times and record average execution time`, () => { | ||
const perRun = measureExecutionTime(runCount, shortTestURI); | ||
assert.equal(perRun < 0.1, true); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
246616
6468