# Is ROOT slower if built with -DCMAKE\_BUILD\_TYPE="Debug"?

**URL:** <https://root-forum.cern.ch/t/is-root-slower-if-built-with-dcmake-build-type-debug/36999>\
**Category:** Newbie\
**Created:** [November 28, 2019, 10:51pm UTC](https://root-forum.cern.ch/t/is-root-slower-if-built-with-dcmake-build-type-debug/36999 "2019-11-28T22:51:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![renyhp](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/e68b1a/32.png) [@renyhp](https://root-forum.cern.ch/u/renyhp)\
**Post date:** [November 28, 2019, 10:51pm UTC](https://root-forum.cern.ch/t/is-root-slower-if-built-with-dcmake-build-type-debug/36999/1 "2019-11-28T22:51:43Z")

</div>

Hello everyone,

Sorry for creating another topic. Question from the title. Will ROOT be slower if I compile it from source with the Debug option, compared to the precompiled binary that I can find on the website? If yes, is there a way to let both coexist and run one or the other selectively (I would run the one with the Debug option if I need to inspect TObjects while debugging, and the default one otherwise)?

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [November 29, 2019, 8:18am UTC](https://root-forum.cern.ch/t/is-root-slower-if-built-with-dcmake-build-type-debug/36999/2 "2019-11-29T08:18:32Z")

</div>

When you compile a program in debug mode it is always slower that an optimized version. You can install/compile a debug version (from source) and switch form a version to an other using:

```auto
source where_ROOT_is_installed/bin/thisroot.sh

```

---

<div class="post-metadata">

**Author:** ![renyhp](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/e68b1a/32.png) [@renyhp](https://root-forum.cern.ch/u/renyhp)\
**Post date:** [November 29, 2019, 5:47pm UTC](https://root-forum.cern.ch/t/is-root-slower-if-built-with-dcmake-build-type-debug/36999/3 "2019-11-29T17:47:12Z")

</div>

Okay, thank you. My concern was that sourcing thisroot.sh wouldn’t be enough if two versions are there.

My other concern is whether I can source thisroot.sh while another istance of ROOT is already running. For example I run

```auto
$ source root-6.18.04/bin/thisroot.sh
$ root -l some-very-long-macro.cpp

```

and while this runs I’m developing something else and my IDE calls

```auto
$ source root-debugversion/bin/thisroot.sh
$ root -l macro-developing.cpp

```

Will this be okay or will it have some bad consequences?

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [November 29, 2019, 6:05pm UTC](https://root-forum.cern.ch/t/is-root-slower-if-built-with-dcmake-build-type-debug/36999/4 "2019-11-29T18:05:43Z")

</div>

Hi @renyhp,  
mainly what `thisroot.sh` does it to set some environment variables _in the shell/session from which it’s is sourced_ (namely `PATH`, `LD_LIBRARY_PATH` and a few others). So you can source two different ROOT versions from two different terminals and run them concurrently without a problem.

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![renyhp](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/e68b1a/32.png) [@renyhp](https://root-forum.cern.ch/u/renyhp)\
**Post date:** [November 29, 2019, 8:25pm UTC](https://root-forum.cern.ch/t/is-root-slower-if-built-with-dcmake-build-type-debug/36999/5 "2019-11-29T20:25:54Z")

</div>

Okay, got it, thank you very much!

---

<div class="post-metadata">

**Author:** ![renyhp](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/e68b1a/32.png) [@renyhp](https://root-forum.cern.ch/u/renyhp)\
**Post date:** [December 12, 2019, 11:02am UTC](https://root-forum.cern.ch/t/is-root-slower-if-built-with-dcmake-build-type-debug/36999/6 "2019-12-12T11:02:00Z")

</div>

Sorry for reusing this thread, I hope it’s not a problem.

Is sourcing `thisroot.sh` even necessary? Will this

```nohighlight
$ source root-no-debug/bin/thisroot.sh
$ root-debug/bin/root.exe mymacro.C

```

possibly cause any problem?

EDIT: Nevermind, I should have tried before posting instead of the other way around. Sorry for pinging.

What I’m really trying to do is getting VSCode to call the debug version of ROOT properly, and using the optimized version for any other case. I have opened [an issue on the vscode github](https://github.com/microsoft/vscode-cpptools/issues/4685) but I still can’t manage to do that. Maybe I’ll compile root with the RelWithDebugInfo configuration and use that one for both debugging and running.
