The increase in size of the compiler sources is about 250 lines of code, i.e. an increase of 7%. It is a non-trivial addition.
That’s pretty significant relative to the size of the Oberon compiler (in other languages it would be considered negligible)
Compiles are typically about 10% faster after implementing the PO2013 Oberon compiler scanner function ORS.Get as a CASE statement.
In other compilers a 10% speedup would be quite noticeable (one coffee less to grab during compilation), but not in Oberon where compilation already is near-instantaneous. PS: I believe this is the only place in the Oberon system where one would see a measurable performance gain (here 10%) speedup (correct me if I’m wrong)
-----Original Message----- From: Oberon [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of Andreas Pirklbauer Sent: Saturday, 17 February 2018 12:16 AM To: ETH Oberon and related systems Subject: [Oberon] CASE without ELSE
PS: I believe this is the only place in the Oberon system where one would see a measurable performance gain (here 10%) speedup (correct me if I’m wrong)
It would take some time (more than I currently have!) to prove whether or not this is the case. I suspect that there is no other single CASE in PO2013 that would have the same impact but there are a few areas in the compiler where CASE statements could be reinstated and the cumulative improvements could be significant. Ones that immediately stand out are ORP.StandFunc, ORP,StandProc and ORP.factor. Look for any procedure which has a collection of more than half-a-dozen ELSIFs that test a single value. Alternatively search for "CASE" in the original Project Oberon source code. There are about 30 instances including a couple of nested CASEs. As spelt out in Arthur Sale's paper that Diego Sardina referred to, the impact of CASE has less effect if the probability of each branch occurring is wildly different. However, this assumes that programmers have bothered to think about which branches are likely to occur more frequently and shuffle their IF-ELSIFs so they are near the top. With the CASE statement you do not have to concern yourself with this sort of hand-optimisation and have more ability to make the source more concise and readable (e.g. order the cases alphabetically) or more closely aligned to the original real-world problem statement (e.g. my Soundex example) . Regards, Chris Burrows CFB Software http://www.astrobe,com/RISC5
participants (2)
-
Andreas Pirklbauer -
Chris Burrows