Algomorph / CodeGrader

A Chrome browser plugin for aiding the teaching assistants grade code style on student's homework project submissions at the CS department of University of Maryland, College Park.
Other
6 stars 4 forks source link

Very Slow Parsing of Code with Many Conditions #187

Open msimmon6 opened 2 years ago

msimmon6 commented 2 years ago

Describe the bug The plug-in takes several minutes to load on a certain project. The only thing that I see in this particular example is the extreme length of certain lines with conditionals.

Where did the bug occur

Semester: Fall 2022 Instructor & Course: Pedram CMSC132 Project name on Submit Server: Proj 1 Student directory id: msivakum

Code segment (if known & relevant): This is what I think is the issue:

boolean blackjackCond = (((dealerCards.get(0).getValue()
== CardValue.Ace) || (dealerCards.get(1).getValue()
== CardValue.Ace)) && ((dealerCards.get(0).getValue()
== CardValue.Ten) || (dealerCards.get(0).getValue()
== CardValue.Jack) || (dealerCards.get(0).getValue()
== CardValue.Queen) || (dealerCards.get(0).getValue()
== CardValue.King) || (dealerCards.get(1).getValue()
== CardValue.Ten) || (dealerCards.get(1).getValue()
== CardValue.Jack) || (dealerCards.get(1).getValue()
== CardValue.Queen) || (dealerCards.get(1).getValue()
== CardValue.King)));

Additional info

I'm not too sure if this is something which needs to be fixed, but it sounds like something to note.

Algomorph commented 2 years ago

This is a known problem, but thanks for posting it here. This is a jsjavaparser problem. I've tried to mitigate this issue in the past -- with partial success -- by manually introducing extra rules in the parser. It may be that the problem has no immediate solution, as the slow-down might be inherent to the PEG.js framework that the parser is built with, i.e. can't fix it short of actually fixing it in PEG.js. I don't think it's worth our time to worry about this, especially at this moment when the future of the Submit Server is being decided.