@@ -102,7 +102,7 @@ cpp_function('int add(int x, int y, int z) {
102102add
103103# > function (x, y, z)
104104# > {
105- # > .Call("_code_1e346b10c362_add ", x, y, z, PACKAGE = "code_1e346b10c362 ")
105+ # > .Call("_code_1e2d15cc8726_add ", x, y, z, PACKAGE = "code_1e2d15cc8726 ")
106106# > }
107107add(1 , 2 , 3 )
108108# > [1] 6
@@ -282,9 +282,9 @@ bench::mark(
282282# > # A tibble: 3 × 6
283283# > expression min median `itr/sec` mem_alloc `gc/sec`
284284# > <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl>
285- # > 1 sum(x) 2.03µs 2.05µs 473760 . 0B 0
286- # > 2 sum_cpp(x) 1.91µs 1.97µs 463325 . 0B 46.3
287- # > 3 sum_r(x) 26.06µs 26.36µs 37310 . 31.7KB 0
285+ # > 1 sum(x) 2.02µs 2.05µs 472291 . 0B 0
286+ # > 2 sum_cpp(x) 1.92µs 1.97µs 467618 . 0B 46.8
287+ # > 3 sum_r(x) 25.91µs 26.18µs 36852 . 31.7KB 0
288288```
289289
290290### Vector input, vector output
@@ -337,8 +337,8 @@ bench::mark(
337337# > # A tibble: 2 × 6
338338# > expression min median `itr/sec` mem_alloc `gc/sec`
339339# > <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl>
340- # > 1 pdist_r(0.5, y) 4.99ms 5.11ms 191 . 7.63MB 95.5
341- # > 2 pdist_cpp(0.5, y) 3.95ms 4ms 249 . 7.63MB 126 .
340+ # > 1 pdist_r(0.5, y) 4.8ms 4.93ms 200 . 7.63MB 102.
341+ # > 2 pdist_cpp(0.5, y) 3.8ms 3.88ms 255 . 7.63MB 127 .
342342```
343343
344344On my computer, it takes around 5 ms with a 1 million element ` y `
@@ -1160,8 +1160,8 @@ bench::mark(
11601160#> # A tibble: 2 × 6
11611161#> expression min median `itr/sec` mem_alloc `gc/sec`
11621162#> <bch:expr> <dbl> <dbl> <dbl> <dbl> <dbl>
1163- #> 1 r 43 .9 44.1 1 32.3 Inf
1164- #> 2 cpp 1 1 43.8 1 NaN
1163+ #> 1 r 42 .9 43.0 1 32.3 10.1
1164+ #> 2 cpp 1 1 42.7 1 1
11651165```
11661166
11671167### R vectorisation versus C++ vectorisation
@@ -1278,9 +1278,9 @@ bench::mark(
12781278# > # A tibble: 3 × 6
12791279# > expression min median `itr/sec` mem_alloc `gc/sec`
12801280# > <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl>
1281- # > 1 vacc1 1.54ms 1.66ms 593 . 7.86KB 35.7
1282- # > 2 vacc2 42.6µs 45.49µs 20528 . 146.68KB 39.0
1283- # > 3 vacc3 12.08µs 12.35µs 79084 . 14.02KB 15.8
1281+ # > 1 vacc1 1.55ms 1.61ms 610 . 7.86KB 33.0
1282+ # > 2 vacc2 41.31µs 43.24µs 20683 . 146.68KB 37.5
1283+ # > 3 vacc3 12.17µs 12.37µs 79650 . 14.02KB 15.9
12841284```
12851285
12861286Not surprisingly, our original approach with loops is very slow.
0 commit comments