2017-02-18 21:36:50 +08:00
# define LOG_NO_INFO 1
2017-06-13 22:25:08 +08:00
# include <fstream>
# include <iostream>
# include <string>
# include <vector>
2017-06-21 17:29:13 +08:00
# include <benchmark/benchmark_api.h>
2017-06-13 22:25:08 +08:00
# include "query/frontend/stripped.hpp"
2016-11-23 00:42:24 +08:00
2018-01-15 22:28:40 +08:00
// clang-format off
const char * kQueries [ ] = {
" MATCH (a) RETURN size(collect(a)) " ,
" CREATE (a:L), (b1), (b2) CREATE (a)-[:A]->(b1), (a)-[:A]->(b2) " ,
" MATCH (a:L)-[rel]->(b) RETURN a, count(*) " ,
" CREATE ({division: 'Sweden'}) " ,
" MATCH (n) RETURN n.division, count(*) ORDER BY count(*) DESC, n.division ASC " ,
" UNWIND ['a', 'b', 'B', null, 'abc', 'abc1'] AS i RETURN max(i) " ,
" CREATE ({created: true}) " ,
" MATCH (a)-[r]-(b) DELETE r, a, b RETURN count(*) AS c " ,
" MATCH (u:User) WITH {key: u} AS nodes DELETE nodes.key " ,
" CREATE ()-[:T {id: 42, alive: true, name: kifla, height: 4.2}]->() " ,
" MATCH p = ()-[r:T]-() WHERE r.id = 42 DELETE r " ,
" UNWIND range(0, 1000) AS i CREATE (:A {id: i}) MERGE (:B {id: i % 10}) " ,
" MATCH (n) WHERE NOT(n.name = 'apa' AND false) RETURN n " ,
" CREATE ()-[:REL {property1: 12, property2: 24}]->() " ,
" MATCH (n:A) WHERE n.name = 'Andres' SET n.name = 'Michael' RETURN n " ,
" MATCH (n:A) SET (n).name = 'memgraph' RETURN n " ,
" CREATE (a {foo: [1, 2, 3]}) SET a.foo = a.foo + [4, 5] RETURN a.foo " ,
" MATCH (n:X {foo: 'A'}) SET n = {foo: 'B', baz: 'C'} RETURN n " ,
" MATCH (n:X {foo: 'A'}) SET n += {foo: null} RETURN n " ,
" MATCH (n) WITH n LIMIT toInteger(ceil(1.7)) RETURN count(*) AS count " ,
" MATCH (a:A), (b:B) MERGE (a)-[r:TYPE]->(b) ON CREATE SET r.name = 'Lola' RETURN count(r) " ,
" CREATE (:L1:L2:L3:L4:L5:L6:L7 {p1: true, p2: 42, p3: \" Here is some text that is not extremely short \" , p4: \" Short text \" , p5: 234.434, p6: 11.11, p7: false}) " ,
} ;
// clang-format on
2016-12-22 22:51:16 +08:00
auto BM_Strip = [ ] ( benchmark : : State & state , auto & function , std : : string query ) {
2017-02-18 18:54:37 +08:00
while ( state . KeepRunning ( ) ) {
for ( int start = 0 ; start < state . range ( 0 ) ; start + + ) {
function ( query ) ;
2016-11-23 00:42:24 +08:00
}
2017-02-18 18:54:37 +08:00
}
state . SetComplexityN ( state . range ( 0 ) ) ;
2016-11-23 00:42:24 +08:00
} ;
2017-06-13 22:25:08 +08:00
int main ( int argc , char * argv [ ] ) {
2021-02-18 22:32:43 +08:00
auto preprocess = [ ] ( const std : : string & query ) { return query : : frontend : : StrippedQuery ( query ) ; } ;
2017-02-18 18:54:37 +08:00
2018-01-15 22:28:40 +08:00
for ( auto test : kQueries ) {
2021-02-18 22:32:43 +08:00
benchmark : : RegisterBenchmark ( test , BM_Strip , preprocess , test ) - > Range ( 1 , 1 ) - > Complexity ( benchmark : : oN ) ;
2017-02-18 18:54:37 +08:00
}
2016-11-23 00:42:24 +08:00
2017-02-18 18:54:37 +08:00
benchmark : : Initialize ( & argc , argv ) ;
benchmark : : RunSpecifiedBenchmarks ( ) ;
2016-11-23 00:42:24 +08:00
2017-02-18 18:54:37 +08:00
return 0 ;
2016-11-23 00:42:24 +08:00
}