@ -133,6 +133,11 @@ void process_bench(std::string target = "./tests/scripts/testfile.test") {
* 2023 - 07 - 04 Archivist - > 2618 ns - 308 ns - 49 ns ( clang + libstdc + + )
* 2023 - 07 - 04 Archivist - > 2618 ns - 308 ns - 49 ns ( clang + libstdc + + )
* 2023 - 07 - 07 Archivist - > 2481 ns - 291 ns - 46 ns ( clang + libc + + )
* 2023 - 07 - 07 Archivist - > 2481 ns - 291 ns - 46 ns ( clang + libc + + )
* 2023 - 07 - 07 Archivist - > 106 ns - 12 ns - 2 ns ( clang + march = native + libc + + )
* 2023 - 07 - 07 Archivist - > 106 ns - 12 ns - 2 ns ( clang + march = native + libc + + )
* ? ? ? ? ? ? ? ? ? ? Archivist : These results above are weird , the benchmark was updated in case something strange went on
* 2023 - 07 - 18 Archivist - > 3446 ns - 405 ns - 65 ns ( gcc + libstdc + + )
* ? ? ? ? ? ? ? ? ? ? Archivist : Corrected some extra weirdness
* 2023 - 07 - 18 Archivist - > 9952 µ s - 234 ns - 30 ns ( gcc + libstdc + + )
*
*/
*/
engine - > registerFunction ( " print " , std : : make_unique < print > ( std : : cout ) ) ;
engine - > registerFunction ( " print " , std : : make_unique < print > ( std : : cout ) ) ;
std : : ifstream src_str ( target ) ;
std : : ifstream src_str ( target ) ;
@ -142,10 +147,12 @@ void process_bench(std::string target = "./tests/scripts/testfile.test") {
decltype ( std : : chrono : : high_resolution_clock : : now ( ) - std : : chrono : : high_resolution_clock : : now ( ) ) per_exec { } , per_step { } , per_op { } ;
decltype ( std : : chrono : : high_resolution_clock : : now ( ) - std : : chrono : : high_resolution_clock : : now ( ) ) per_exec { } , per_step { } , per_op { } ;
for ( int runs = 0 ; runs < 5000 ; runs + + ) {
constexpr size_t runs_count = 500 ;
for ( int runs = 0 ; runs < runs_count ; runs + + ) {
auto res = engine - > prepare ( code . str ( ) ) ;
auto res = engine - > prepare ( code . str ( ) ) ;
engine - > clear_variables ( ) ;
auto begin = std : : chrono : : high_resolution_clock : : now ( ) ;
auto begin = std : : chrono : : high_resolution_clock : : now ( ) ;
while ( not engine - > getValue ( " exit_ctr " ) . has_value ( ) ) {
while ( not engine - > getValue ( " exit_ctr " ) . has_value ( ) ) {
engine - > stepOnce ( ) ;
engine - > stepOnce ( ) ;
@ -156,13 +163,16 @@ void process_bench(std::string target = "./tests/scripts/testfile.test") {
per_step + = ( end - begin ) ;
per_step + = ( end - begin ) ;
per_op + = ( end - begin ) ;
per_op + = ( end - begin ) ;
}
}
per_exec / = 5000 ;
auto executed_ops = ( runs_count * engine - > op_count ( ) * 5000 /* The code loops 5000 times */ ) ;
per_exec / = runs_count ;
per_step / = steps ;
per_step / = steps ;
per_op = per_op / 5000 / 53 ;
per_op = per_op / n">executed_ops ;
std : : cout < < " time per exec = " < < std : : chrono : : duration_cast < std : : chrono : : nan oseconds> ( per_exec ) . count ( ) < < " n s\n " ;
std : : cout < < " time per step = " < < std : : chrono : : duration_cast < std : : chrono : : nanoseconds > ( per_step ) . count ( ) < < " ns \n " ;
std : : cout < < " time per avg op = " < < std : : chrono : : duration_cast < std : : chrono : : nanoseconds > ( per_op ) . count ( ) < < " ns \n " ;
std : : cout < < " time per exec ( " < < runs_count < < " ) = " < < std : : chrono : : duration_cast < std : : chrono : : micr oseconds> ( per_exec ) . count ( ) < < " µ s\n " ;
std : : cout < < " time per step ( " < < steps < < " , around " < < ( double ) executed_ops / steps < < " op/s) = " < < std : : chrono : : duration_cast < std : : chrono : : nanoseconds > ( per_step ) . count ( ) < < " ns \n " ;
std : : cout < < " time per avg op ( " < < executed_ops < < " by groups of " < < engine - > op_count ( ) < < " ) = " < < std : : chrono : : duration_cast < std : : chrono : : nanoseconds > ( per_op ) . count ( ) < < " ns \n " ;
}
}
void compile_bench ( std : : string target = " ./tests/scripts/testfile.test " ) {
void compile_bench ( std : : string target = " ./tests/scripts/testfile.test " ) {
@ -176,26 +186,34 @@ void compile_bench(std::string target = "./tests/scripts/testfile.test") {
* Same as above but for compilation times
* Same as above but for compilation times
*
*
* 2023 - 07 - 04 Archivist - > 386 µ s
* 2023 - 07 - 04 Archivist - > 386 µ s
* 2023 - 07 - 18 Archivist - > 166 µ s
* 2023 - 07 - 18 Archivist - > 156 µ s
*/
*/
engine - > registerFunction ( " print " , std : : make_unique < print > ( std : : cout ) ) ;
engine - > registerFunction ( " print " , std : : make_unique < print > ( std : : cout ) ) ;
std : : ifstream src_str ( " ./tests/scripts/testfile.test " ) ;
std : : ifstream src_str ( " ./tests/scripts/testfile.test " ) ;
std : : stringstream code ;
std : : stringstream code ;
code < < src_str . rdbuf ( ) ;
code < < src_str . rdbuf ( ) ;
auto begin = std : : chrono : : high_resolution_clock : : now ( ) ;
constexpr size_t daruns_count = 100 ;
[ & ] ( ) __attribute__ ( ( optimize ( " O0 " ) ) ) {
auto res = engine - > prepare ( code . str ( ) ) ;
res = engine - > prepare ( code . str ( ) ) ;
res = engine - > prepare ( code . str ( ) ) ;
res = engine - > prepare ( code . str ( ) ) ;
res = engine - > prepare ( code . str ( ) ) ;
} ( ) ;
auto begin = std : : chrono : : high_resolution_clock : : now ( ) ;
for ( size_t i = 0 ; i < daruns_count ; + + i ) {
[ & ] ( ) __attribute__ ( ( optimize ( " O0 " ) ) ) {
auto res = engine - > prepare ( code . str ( ) ) ;
res = engine - > prepare ( code . str ( ) ) ;
res = engine - > prepare ( code . str ( ) ) ;
res = engine - > prepare ( code . str ( ) ) ;
res = engine - > prepare ( code . str ( ) ) ;
res = engine - > prepare ( code . str ( ) ) ;
res = engine - > prepare ( code . str ( ) ) ;
res = engine - > prepare ( code . str ( ) ) ;
res = engine - > prepare ( code . str ( ) ) ;
res = engine - > prepare ( code . str ( ) ) ;
} ( ) ;
}
auto end = std : : chrono : : high_resolution_clock : : now ( ) ;
auto end = std : : chrono : : high_resolution_clock : : now ( ) ;
auto per_exec = ( end - begin ) / 5 ;
auto per_exec = ( end - begin ) / 10 / daruns_count ;
std : : cout < < " time per exec = " < < std : : chrono : : duration_cast < std : : chrono : : microseconds > ( per_exec ) . count ( ) < < " µs \n " ;
std : : cout < < " time per exec = " < < std : : chrono : : duration_cast < std : : chrono : : microseconds > ( per_exec ) . count ( ) < < " µs \n " ;
}
}
@ -206,7 +224,11 @@ void compare(std::string target, std::string expect) {
engine - > registerFunction ( " exit " , std : : make_unique < terminate > ( ) ) ;
engine - > registerFunction ( " exit " , std : : make_unique < terminate > ( ) ) ;
engine - > registerFunction ( " set " , std : : make_unique < set > ( ) ) ;
engine - > registerFunction ( " set " , std : : make_unique < set > ( ) ) ;
engine = scripting : : register_array_lib ( std : : move ( engine ) , true , 4096 ) ;
constexpr size_t array_limit = 4096 ;
constexpr size_t string_limit = 4096 ;
engine = scripting : : register_array_lib ( std : : move ( engine ) , true , array_limit ) ;
engine = scripting : : register_crypto_lib ( std : : move ( engine ) , array_limit , string_limit ) ;
std : : stringstream str ;
std : : stringstream str ;
std : : string_view filename_source = target ;
std : : string_view filename_source = target ;