Dictionary entry vs. compiling & loading class

Hi,

I have a class (MyClass.cpp) that I want to load and use in a macro (my_macro.C). What is the difference between (a) compiling & loading the class to memory and (b) making a dictionary entry?

i.e.

(a)
gROOT->ProcessLine(".L MyClass.cpp+");
gROOT->ProcessLine(".x my_macro.C+");

vs.

(b)
including
#pragma link C++ class MyClass+;

in the macro and then simply running
gROOT->ProcessLine(".x my_macro.C+");

Edit: Let me make myself a bit more clear. In (a), I get a MyClass.so file; in (b) I don’t. In (b) the execution of my_macro starts much faster than in (a). I was wondering if that means that the code in (b) is not optimized(?) and/or if it runs slower than in (a).

Thanks.

–Christos

Hi,

There are 2 main differences.

In your case a), it exposes to CINT all the symbols declared in MyClass.cpp and MyClass.h, my_macro.C (and my_macro.h).

In b), it exposes to CINT ‘only’ the class MyClass, and the symbols in my_macro.C (and my_macro.h).

Also in a) you generate 2 dictionaries and compile/link 2 separate shared library.
In b) you generate only 1 dictionary and compile/link onlu 1 shared library.

So in conclusion b) is faster but possibly do not expose as much to CINT.

Cheers,
Philippe.

Hi Philippe,

So, the startup time is smaller in (b). What about the execution time? Are (a) and (b) equivalent?

–Christos

The execution time should be the same.

Cheers,
Philippe.