Loading ...
Sorry, an error occurred while loading the content.

Re: KNOWN spells (using variables)

Expand Messages
  • Byngl
    I just wrote a quick test to test this. I made a for loop that called 100000 iterations for 3 different cases as follows: common: int loopCount; long t_start;
    Message 1 of 15 , Mar 1, 2005
    • 0 Attachment
      I just wrote a quick test to test this. I made a for loop that called
      100000 iterations for 3 different cases as follows:

      common:
      int loopCount;
      long t_start;
      long t_stop;
      int t;
      String formula = "1";

      1)
      t_start = System.currentTimeMillis();
      for(loopCount = 100000; loopCount > 0; --loopCount)
      {
      t = aPC.getVariableValue(formula, "").intValue();
      }
      t_stop = System.currentTimeMillis();
      System.err.println(Long.toString(t_stop - t_start));

      average time in ms for 20 attempts: 36.65


      2)
      hasSpellFormulas = false;

      t_start = System.currentTimeMillis();
      for(loopCount = 100000; loopCount > 0; --loopCount)
      {
      if (hasSpellFormula())
      {
      t = aPC.getVariableValue(formula, "").intValue();
      }
      else
      {
      t = Integer.parseInt(formula);
      }
      }
      t_stop = System.currentTimeMillis();
      System.err.println(Long.toString(t_stop - t_start));

      average time in ms for 20 attempts: 15.75


      3)
      hasSpellFormulas = true;

      t_start = System.currentTimeMillis();
      for(loopCount = 100000; loopCount > 0; --loopCount)
      {
      if (hasSpellFormula())
      {
      t = aPC.getVariableValue(formula, "").intValue();
      }
      else
      {
      t = Integer.parseInt(formula);
      }
      }
      t_stop = System.currentTimeMillis();
      System.err.println(Long.toString(t_stop - t_start));

      average time in ms for 20 attempts: 34.4


      Byngl

      --- In pcgen@yahoogroups.com, Frugal <frugal@p...> wrote:
      > The first thing that the parser does is check to see if the
      argument is
      > a number or not. If it is a number it just returns the numeric
      value of
      > the argument. So there is no speed penalty to having a tag always
      taking
      > a formula. In fact it will be quicker than having to check this new
      tag
      > to see if it a formula and then having the parser perform pretty
      much
      > the same check again...
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.