bugGrammatica - Bugs: bug #7998, Possible divide by zero when...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #7998: Possible divide by zero when running --profile

Submitted by:  Per Cederberg <cederberg>
Submitted on:  Thu 04 Mar 2004 09:05:05 AM UTC  
 
Severity:  2 - Normal Item Group:  Software
Status:  Fixed Assigned to:  Per Cederberg <cederberg>
Open/Closed:  Closed

Sat 14 Mar 2009 09:34:51 AM UTC, comment #3: 

Version 1.5 was released on 2009-03-07. Closing this issue.

Per Cederberg <cederberg>
Project AdministratorIn charge of this item.
Wed 24 Mar 2004 08:11:13 PM UTC, comment #2: 

This has been resolved by always adding 1 millisecond to the time measured. The fix has been pushed to CVS and will appear in the next release (probably 1.5).

Per Cederberg <cederberg>
Project AdministratorIn charge of this item.
Wed 24 Mar 2004 07:43:55 PM UTC, comment #1: 

Also reported on the mailing list by Stefan Ukena.

Per Cederberg <cederberg>
Project AdministratorIn charge of this item.
Thu 04 Mar 2004 09:05:05 AM UTC, original submission:  

In some cases, for very short inputs, the --profile counts zero (0) milliseconds of execution time. This in turn will cause a divide by zero error when attempting to calculate the average parsing speed.

As reported by Lukas Zapletal:

Try to: gramm arithmetic.grammar --profile

Tokenizing a-test.data

Time elapsed:  0 millisec
Tokens found:  11
INTERNAL ERROR: ...
java.lang.ArithmeticException: / by zero
at net.percederberg.grammatica.Grammatica.profile(Grammatica.java:522)      
at net.percederberg.grammatica.Grammatica.main(Grammatica.java:175)

Bug is here:
System.out.println("  Time elapsed:  " + time + " millisec");
System.out.println("  Tokens found:  " + counter);
System.out.println("  Average speed: " + (counter / time) + "tokens/millisec"); *** HERE - divide by zero ***
System.out.println();

Per Cederberg <cederberg>
Project AdministratorIn charge of this item.

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by cederberg (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-03-14 cederberg Open/ClosedOpen => Closed
        Discussion LockUnlocked => Locked
    2004-03-24 cederberg StatusNone => Fixed

    Back to the top


    Powered by Savane 3.5