brodieG / unitizer

Easy R Unit Tests
Other
39 stars 6 forks source link

Slow Interactions Recently #262

Closed brodieG closed 4 years ago

brodieG commented 4 years ago

Last time I looked into a failing unitizer it ran very slowly. It might have been due to a large set of loaded namespaces. Need to examine this.

brodieG commented 4 years ago

Oddly the slowness is after an expression is computed at the prompt, manifesting between result display and new prompt display. But help display is fast. History?

Oh boy, someone added a gc to showConnections:

> f <- tempfile()
> zz <- unitizer:::history_capt(f)
> unitizer:::history_write('hello')
Error in unitizer:::history_write("hello") : 
  is.open_con(hist.con) is not TRUE
> unitizer:::history_write(zz$con, 'hello')
> hello
Error: object 'hello' not found
> unitizer:::history_write(zz$con, 'hello')
> treeprof::treeprof( unitizer:::history_write(zz$con, 'hello'))
Profiling
auto gc: running with gc() first
First run in 0.538 seconds
Looping to 5 seconds
Parsing Rprof
Done
Ticks: 1589; Iterations: 10; Time Per: 401.0 milliseconds; Time Total: 4.010 seconds; Time Ticks: 1.589

                                              milliseconds
unitizer:::history_write ----------------- : 401.0 -   0.0
    stopifnot ---------------------------- : 143.3 -   0.0
    |   ...elt --------------------------- : 143.3 -   0.0
    |       is.open_con ------------------ : 143.3 -   0.0
    |           isTRUE ------------------- : 143.3 -   0.0
    |               is.valid_con --------- : 143.3 -   0.0
    |                   showConnections -- : 143.3 -   0.0
    |                       gc ----------- : 143.3 - 143.3
    try ---------------------------------- : 138.3 -   0.0
    |   loadhistory ---------------------- : 138.3 -   0.0
    |       showConnections -------------- : 138.3 -   0.0
    |           gc ----------------------- : 138.3 - 138.3
    is.open_con -------------------------- : 119.1 -   0.0
        isTRUE --------------------------- : 119.1 -   0.0
            is.valid_con ----------------- : 119.1 -   0.0
                showConnections ---------- : 119.1 -   0.0
                    gc ------------------- : 119.1 - 119.1