1 2 #include <cpp11/R.hpp> 3 #include <cpp11/integers.hpp> 4 #include <cpp11/sexp.hpp> 5 6 #include <cli/progress.h> 7 8 [[cpp11::register]] test_baseline_()9int test_baseline_() { 10 int res = 0; 11 for (int i = 0; i < 2000000000; i++) { 12 res += i % 2; 13 } 14 return res; 15 } 16 17 [[cpp11::register]] test_cli_()18int test_cli_() { 19 int res = 0; 20 cpp11::sexp bar = cli_progress_bar(2000000000, NULL); 21 for (int i = 0; i < 2000000000; i++) { 22 if (CLI_SHOULD_TICK) cli_progress_set(bar, i); 23 res += i % 2; 24 } 25 return res; 26 } 27 28 [[cpp11::register]] test_template_()29int test_template_() { 30 int res = 0; 31 cpp11::sexp bar = cli_progress_bar(2000000000, NULL); 32 cli_progress_set_format( 33 bar, 34 "{%d} package{?s} {cli::pb_bar} | {cli::pb_elapsed}", 35 4 36 ); 37 for (int i = 0; i < 2000000000; i++) { 38 if (CLI_SHOULD_TICK) cli_progress_set(bar, i); 39 res += i % 2; 40 } 41 return res; 42 } 43