Closed iafisher closed 4 years ago
Option 2 isn't good because if the script or question has an error, the user won't find out until the middle of the quiz.
When I replaced the Python script with a simple C stand-in, parsing was almost instantaneous again, which indicates that one possible solution is just writing faster scripts.
Option 2 also wouldn't speed up runs that do require parsing every question, like the count subcommand.
Expanding on option 1: add a new server-script
tag so that it's opt-in. The quiz parser spawns the script the first time it is encountered and keeps it running for the duration of parsing. For each question, it writes the two or more lines to the script's standard input: the text of the question, zero or more lines of answers, and some end-of-message line (e.g., END
, but probably something less generic so there's no risk of it coinciding with an actual answer). For each question, the script should respond the same way as in the old protocol. Finally, the parser will write END_OF_QUIZ
or something to shut the process down.
Solution: re-write the slow script in a faster language, like Rust.
Two ideas