Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip modify_level(by) performance investigation #159

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nfultz
Copy link
Contributor

@nfultz nfultz commented Oct 18, 2018

Some benchmarking



# here we want at least one of each ideo st there aren't random failures in assn 9
draw_ideo <- function(N) {
  x <- c("Liberal", "Moderate", "Conservative")
  x <- c(x, sample(x, size=N-3, prob=c(.2,.3,.5), replace=TRUE))
  sample(x)
}

population <- function(N) fabricate(
  villages = add_level(
    N = N, elevation = rnorm(N),
    high_elevation = as.numeric(elevation > 0)
  ),
  individuals = add_level(N = 10, noise = rnorm(N)),
  individuals = modify_level(ideo_3 = draw_ideo(N), by = "villages")
)

population2 <- function(N) fabricate(
  villages = add_level(
    N = N, elevation = rnorm(N),
    high_elevation = as.numeric(elevation > 0)
  ),
  individuals = add_level(N = 10, noise = rnorm(N)),
  individuals = modify_level2(ideo_3 = draw_ideo(N), by = "villages")
)

require(profvis)
profvis(population())


microbenchmark::microbenchmark(population(100), population2(100),
                               population(200), population2(200),
                               population(300), population2(400),
                               population(800), population2(800),
                               population(1600), population2(1600))

image

> summary(lm(log(t)~log(N):which + which, df))

Call:
lm(formula = log(t) ~ log(N):which + which, data = df)

Residuals:
        Min          1Q      Median          3Q         Max 
-0.52720065 -0.15539903  0.00375551  0.17617271  1.23373942 

Coefficients:
                           Estimate  Std. Error    t value   Pr(>|t|)    
(Intercept)             -7.45114549  0.06281345 -118.62340 < 2.22e-16 ***
whichpopulation2         1.15412551  0.08955341   12.88757 < 2.22e-16 ***
log(N):whichpopulation   1.25744811  0.01044202  120.42193 < 2.22e-16 ***
log(N):whichpopulation2  1.02387495  0.01051372   97.38464 < 2.22e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.2304528 on 996 degrees of freedom
Multiple R-squared:  0.9603536,	Adjusted R-squared:  0.9602341 
F-statistic: 8042.017 on 3 and 996 DF,  p-value: < 2.2204e-16

@coveralls
Copy link

Coverage Status

Coverage decreased (-3.3%) to 95.605% when pulling 8331507 on nfultz/modify_by_performance into fa31dab on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants