Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance deficite dute to map key type std::string #1

Open
Expander opened this issue Aug 7, 2013 · 1 comment
Open

Performance deficite dute to map key type std::string #1

Expander opened this issue Aug 7, 2013 · 1 comment

Comments

@Expander
Copy link
Collaborator

Expander commented Aug 7, 2013

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:

  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

  template <class key_type = std::string>
  class Coll { ... };

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

  int main() {
    ifstream ifs("slha1.txt");
    Coll<SLHAea::BlockNames> 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

@Expander
Copy link
Collaborator Author

Dear Frank Thomas,

after looking into your code and studying the SLHA standard a bit, I think my above proposal doen not make much sense. This is because the SLHA standard allows user-defined blocks, which cannot be handled by an enum which you use as template parameter.

Best,
Alex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant