MCPcopy
hub / github.com/parse-community/parse-server / benchmarkQueryRegex

Function benchmarkQueryRegex

benchmark/performance.js:719–744  ·  view source on GitHub ↗

* Benchmark: Query $regex * * Measures a standard Parse.Query.find() with a $regex constraint. * Each iteration uses a different regex to avoid database query cache hits.

(name)

Source from the content-addressed store, hash-verified

717 * Each iteration uses a different regex to avoid database query cache hits.
718 */
719async function benchmarkQueryRegex(name) {
720 // Seed objects that will match the various regex patterns
721 const objects = [];
722 for (let i = 0; i < 1_000; i++) {
723 const obj = new Parse.Object('BenchmarkRegex');
724 obj.set('field', `BenchRegex_${i} data`);
725 objects.push(obj);
726 }
727 await Parse.Object.saveAll(objects);
728
729 let counter = 0;
730
731 const bases = ['^BenchRegex_', 'BenchRegex_', '[a-z]+_'];
732
733 return measureOperation({
734 name,
735 iterations: 1_000,
736 operation: async () => {
737 const idx = counter++;
738 const regex = bases[idx % bases.length] + idx;
739 const query = new Parse.Query('BenchmarkRegex');
740 query._addCondition('field', '$regex', regex);
741 await query.find();
742 },
743 });
744}
745
746/**
747 * Benchmark: LiveQuery $regex end-to-end

Callers

nothing calls this directly

Calls 2

measureOperationFunction · 0.85
findMethod · 0.65

Tested by

no test coverage detected