fthomas / fthomas/slhaea

Performance deficite dute to map key type std::string

Open
#1 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
8
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Dear Frank Thomas,

I'm planning to use your SLHAea package in my own spectrum generator because it looks very elegant and seems to be easy to use.

However, speed is a critical point for me, so I wonder how SLHAea performs compared to SLHALib (http://www.feynarts.de/slha/) or other hand-written SLHA libraries? My wish would be that reading and writing time together is much smaller than 0.1 ms. Have you done some speed comparisons with other libraries?

There is one problematic point which I have in mind: You are using `std::string` as map key in your examples:

``` C++
ifstream ifs("slha1.txt");
Coll input(ifs);

cout << "tan(beta) = " << input["MINPAR"][3][1] << '\n';
cout << "m_top(pole) line:\n" << input["SMINPUTS"][6] << '\n';
cout << "SMINPUTS block:\n" << input["SMINPUTS"];
```

It could be that this is rather slow compared to an integer key (depending on the `std::map` implementation). So, using enums as an alternative would probably help here.

One possibility to achieve this would be to make the key type a template parameter which can be chosen by the user at compile time

``` C++
template
class Coll { ... };

namespace SLHAea {
enum BlockNames : int { MINPAR, SMINPUTS, ... };
}

int main() {
ifstream ifs("slha1.txt");
Coll input(ifs);

cout << "tan(beta) = " << input[SLHAea::MINPAR][3][1] << '\n';
cout << "m_top(pole) line:\n" << input[SLHAea::SMINPUTS][6] << '\n';
cout << "SMINPUTS block:\n" << input[SLHAea::SMINPUTS];
}
```

What do you think about this option?

Best regards,
Alexander Voigt

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.