const Benchmark = require('benchmark');
const debug = require('debug')('bench');

debug('will load database');
const db = require('./lib/communes').getIndexedDb();
debug('database loaded');

const suite = new Benchmark.Suite;

suite
  .add('spatial search (point)', function() {
    db.queryByLonLat([6.175882816314696, 49.11830706404367]);
  })
  .add('text search', function() {
    db.queryByName('metz');
  })
  .add('CP search', function() {
    db.queryByCP('54490');
  })
  .on('cycle', function(event) {
    debug(String(event.target));
  })
  .on('complete', function() {
    debug('Fastest is %s', this.filter('fastest').map('name'));
    debug('Memory usage: %s', JSON.stringify(process.memoryUsage()));
  })
  // run async
  .run({ 'async': true });

@@ -283,22 +283,33 @@
  db.
-queryByLonLat(
+search(%7B pointInContour: 
 %5B6.1
@@ -342,16 +342,18 @@
 6404367%5D
+ %7D
 );%0A  %7D)%0A
@@ -398,26 +398,30 @@
  db.
-queryByName(
+search(%7B nom: 
 'metz'
+ %7D
 );%0A 
@@ -468,25 +468,38 @@
  db.
-queryByCP(
+search(%7B codePostal: 
 '54490'
+ %7D
 );%0A 

Update bench