"use strict";

const benchmark = require("benchmark");

const { select, where, anyOf, allOf, lessThan, moreThan, unsafeSQL, parameter } = require("../src/operations");

let suite = new benchmark.Suite();

suite
	.add("Build standard query", () => {
		let query = select("projects", [
			where({
				foo: anyOf([ "bar", "baz", anyOf([ "bar2", "baz2" ]), unsafeSQL("TRUE") ]),
				qux: anyOf([ 13, moreThan(42) ]),
				complex: anyOf([
					30,
					40,
					allOf([
						moreThan(100),
						lessThan(200),
						lessThan(parameter("max"))
					])
				])
			}),
			where({ second: 2 })
		]);
	})
	.on("cycle", (event) => {
		console.log(String(event.target));
	})
	.on("complete", function () {
		console.log('Fastest is ' + this.filter('fastest').map('name'));
	})
	.run({
		async: true,
		minSamples: 500
	});
