Skip to content

Most recent function is faster #14

@EmilHvitfeldt

Description

@EmilHvitfeldt

I was doing some benchmarking and got some strange results.

I think I got it minimal enough now. It appears that any function when being defined adds calling time to any previous functions.

library(cpp11)

cpp_function("void void_a() {}")
cpp_function("void void_b() {}")

bm <- bench::mark(
  void_a(),
  void_b()
)

plot(bm)
#> Loading required namespace: tidyr

cpp_function("void void_b() {}")
cpp_function("void void_a() {}")

bm <- bench::mark(
  void_a(),
  void_b()
)

plot(bm)

Created on 2020-06-17 by the reprex package (v0.3.0)

library(cpp11)

cpp_function("void void_a() {}")
cpp_function("void void_b() {}")
cpp_function("void void_c() {}")
cpp_function("void void_d() {}")
cpp_function("void void_e() {}")

bm <- bench::mark(
  void_a(),
  void_b(),
  void_c(),
  void_d(),
  void_e()
)

plot(bm)
#> Loading required namespace: tidyr

Created on 2020-06-17 by the reprex package (v0.3.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions