# Pkg.test() is orders of magnitude slower than include("test/runtests.jl")

**URL:** <https://discourse.julialang.org/t/pkg-test-is-orders-of-magnitude-slower-than-include-test-runtests-jl/64235>\
**Category:** Performance\
**Created:** [July 7, 2021, 8:53pm UTC](https://discourse.julialang.org/t/pkg-test-is-orders-of-magnitude-slower-than-include-test-runtests-jl/64235 "2021-07-07T20:53:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brad\_Carman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brad_carman/32/17631_2.png) [@Brad\_Carman](https://discourse.julialang.org/u/Brad_Carman)\
**Post date:** [July 7, 2021, 8:53pm UTC](https://discourse.julialang.org/t/pkg-test-is-orders-of-magnitude-slower-than-include-test-runtests-jl/64235/1 "2021-07-07T20:53:58Z")

</div>

If I run the following (starting Julia with only `--project` switch)

```julia
include("test/runtests.jl")

```

`@time` of my function gives

> 0.030818 seconds (130.79 k allocations: 7.158 MiB)

But, if I run

```julia
using Pkg; Pkg.test(;julia_args=`--check-bounds=no`)

```

Then the result is:

> 1.420798 seconds (148.56 k allocations: 8.402 MiB)

Other than `--check-bounds`, what else could be causing a major slow down?

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [July 7, 2021, 9:14pm UTC](https://discourse.julialang.org/t/pkg-test-is-orders-of-magnitude-slower-than-include-test-runtests-jl/64235/2 "2021-07-07T21:14:39Z")

</div>

It starts a new Julia process which means it also needs to load any packages, compile functions, etc for the first time (just like when you start a new Julia session).

---

<div class="post-metadata">

**Author:** ![Brad\_Carman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brad_carman/32/17631_2.png) [@Brad\_Carman](https://discourse.julialang.org/u/Brad_Carman)\
**Post date:** [July 7, 2021, 9:17pm UTC](https://discourse.julialang.org/t/pkg-test-is-orders-of-magnitude-slower-than-include-test-runtests-jl/64235/3 "2021-07-07T21:17:07Z")

</div>

Sorry I should have explained, I’m using `@time` on my function call (several times to avoid compilation timing and I’m report the last run). So this does not include the time of loading packages, etc. I’m seeing a very different performance of my package during testing vs. directly running my test script.

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [July 7, 2021, 9:20pm UTC](https://discourse.julialang.org/t/pkg-test-is-orders-of-magnitude-slower-than-include-test-runtests-jl/64235/4 "2021-07-07T21:20:31Z")

</div>

Ah ok, that makes sense. Maybe code coverage or deprecation warnings? The command Pkg uses is here btw: [Pkg.jl/Operations.jl at 90b535df2467cade9f1e63c1607fbc0ddf2303a4 · JuliaLang/Pkg.jl · GitHub](https://github.com/JuliaLang/Pkg.jl/blob/90b535df2467cade9f1e63c1607fbc0ddf2303a4/src/Operations.jl#L1371)

---

<div class="post-metadata">

**Author:** ![Brad\_Carman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brad_carman/32/17631_2.png) [@Brad\_Carman](https://discourse.julialang.org/u/Brad_Carman)\
**Post date:** [July 7, 2021, 9:23pm UTC](https://discourse.julialang.org/t/pkg-test-is-orders-of-magnitude-slower-than-include-test-runtests-jl/64235/5 "2021-07-07T21:23:37Z")

</div>

OK, I found the solution.

I included at the top of `runtests.jl` the following:

```julia
display(Base.JLOptions())

```

Then I compared the options in test mode and script mode. Turns out `depwarn` was the culprit.

So now when running:

```julia
using Pkg; Pkg.test(;julia_args=`--depwarn=no`)

```

now gives the same time as running `include("test/runtests.jl")`
