Skip to content

Instantly share code, notes, and snippets.

@JackHo327
Last active August 2, 2020 02:39
Show Gist options
  • Select an option

  • Save JackHo327/c9b1f89fc22404b8d38d4c8c94e8bcd3 to your computer and use it in GitHub Desktop.

Select an option

Save JackHo327/c9b1f89fc22404b8d38d4c8c94e8bcd3 to your computer and use it in GitHub Desktop.

Revisions

  1. JackHo327 revised this gist Aug 2, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions r_func_performance_microbenchmark.R
    Original file line number Diff line number Diff line change
    @@ -8,5 +8,5 @@
    # firstly, type "?microbenchmark" to check its user doc
    > microbenchmark(for_fun(100000), times = 100)
    Unit: milliseconds
    expr min lq mean median uq max neval
    for_fun(1e+05) 94.68666 105.8318 112.9071 107.9177 112.2817 183.2506 100
    expr min lq mean median uq max neval
    for_fun(1e+05) 94.68666 105.8318 112.9071 107.9177 112.2817 183.2506 100
  2. JackHo327 renamed this gist Aug 2, 2020. 1 changed file with 0 additions and 1 deletion.
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,4 @@
    > ret <- numeric(100000)

    > for_fun <- function(x){
    for(i in 1:x){
    ret[i] <- i^2
  3. JackHo327 revised this gist Jul 2, 2020. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions func_performance_02.R
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,13 @@
    ret <- numeric(100000)
    > ret <- numeric(100000)

    for_fun <- function(x){
    > for_fun <- function(x){
    for(i in 1:x){
    ret[i] <- i^2
    }
    }

    # firstly, type "?microbenchmark" to check its user doc
    microbenchmark(for_fun(100000), times = 100)
    > microbenchmark(for_fun(100000), times = 100)
    Unit: milliseconds
    expr min lq mean median uq max neval
    for_fun(1e+05) 94.68666 105.8318 112.9071 107.9177 112.2817 183.2506 100
  4. JackHo327 revised this gist Jul 2, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions func_performance_02.R
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    ret <- numeric(100000)

    for_fun <- function(x){
    for(i in 1:x){
    ret[i] <- i^2
  5. JackHo327 revised this gist Jul 2, 2020. 1 changed file with 9 additions and 9 deletions.
    18 changes: 9 additions & 9 deletions func_performance_02.R
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,12 @@
    > ret <- numeric(100000)
    > for_fun <- function(x){
    + for(i in 1:x){
    + ret[i] <- i^2
    + }
    + }
    ret <- numeric(100000)
    for_fun <- function(x){
    for(i in 1:x){
    ret[i] <- i^2
    }
    }

    # firstly, type "?microbenchmark" to check its user doc
    > microbenchmark(for_fun(100000), times = 100)
    microbenchmark(for_fun(100000), times = 100)
    Unit: milliseconds
    expr min lq mean median uq max neval
    for_fun(1e+05) 94.68666 105.8318 112.9071 107.9177 112.2817 183.2506 100
    expr min lq mean median uq max neval
    for_fun(1e+05) 94.68666 105.8318 112.9071 107.9177 112.2817 183.2506 100
  6. JackHo327 created this gist Jul 2, 2020.
    12 changes: 12 additions & 0 deletions func_performance_02.R
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    > ret <- numeric(100000)
    > for_fun <- function(x){
    + for(i in 1:x){
    + ret[i] <- i^2
    + }
    + }

    # firstly, type "?microbenchmark" to check its user doc
    > microbenchmark(for_fun(100000), times = 100)
    Unit: milliseconds
    expr min lq mean median uq max neval
    for_fun(1e+05) 94.68666 105.8318 112.9071 107.9177 112.2817 183.2506 100