mmomtchev / igc-xc-score

A scoring program for gliding competitions striving for 100% accuracy and determinism
GNU Lesser General Public License v3.0
42 stars 9 forks source link

Strip/tree shake debug code #13

Open vicb opened 3 years ago

vicb commented 3 years ago

It would be nice to be able to strip (or tree shake) the debug/test geojson code especially to reduce the payload for websites.

For tree shaking the debug code should be moved out of the class.

Maybe also switch to Typescript ?

mmomtchev commented 3 years ago

The gain will be less than 1Kb I think? But still, maybe there should be some way to remove that code altogether in a production buiild When I started this project, it was meant as a support tool, along igc-admin-analyze, for my linear regression analysis of weather data and XC scores - a project that did not turn out to be a great success - except for rediscovering the importance of ambient pressure already known since the Age of Sail

Just as pfd, it was initially a Python project with multithreading support Then, at some point, I decided to hastily hack a JS version - a monothreaded one - to compare the performance - and to my greatest surprise, the mono-threaded JS version outperformed the Python multithreaded one - with or without PyPy

So in fact, this project grew out of a hack and I considered it mostly abandonware :smile:

Initially I didn't want to have any dependencies, but now that it is an ES6 module that must be transpiled anyway, I could as well use Typescript. But in fact, just a few days ago I was even considering a complete rewrite in C++ - so that it can be embedded in flight instruments. This year is going to be my first year with a real flight computer and I am still looking at all available options - and whatever I choose, I will surely consider an embedded port. I will probably start with an Onyx Boox.

vicb commented 3 years ago

The gain will be less than 1Kb I think? But still, maybe there should be some way to remove that code altogether in a production buiild

There is no small gain ;)

Making it tree shakeable should be easy, just move the method out of the classes in a different module. You can still access the members (it might look like getBoxJson(box)).

Those days the v8 VM is pretty efficient and I would be curious about the gain you can have with a C++ implementation. Still it is possible to compile C++ to WebASM.

With regards to flight instruments I like XCTrack on Android, FlyME on Android is nice too and they can already optimize the flights in real time. I run XCTrack on a $100 android phone.

mmomtchev commented 3 years ago

XCTrack is currently my first choice - initially I intended to write my own :smile: - but XCTrack is so good that one cannot justify rewriting it One of the authors of XCTrack is Ondrej who is the original creator of this algorithm, yet there is no scoring in it?

mmomtchev commented 3 years ago

I was also thinking about adding support for Box points - so that it can show you a score-maximizing point in a, let's say 3km or 5km radius - by closing a triangle or by getting closer to an FAI triangle - but there is not point implementing this in JS/TS - this feature belongs to a C++ implementation

vicb commented 3 years ago

One of the authors of XCTrack is Ondrej who is the original creator of this algorithm, yet there is no scoring in it?

Yes there is scoring.

vicb commented 3 years ago

I just stumbled upon https://github.com/igclib/igclib/blob/master/src/xc/xcopt.cpp

vicb commented 3 years ago

Also Tom Payne has a C implementation (used by the FFVL). It might be interesting to contact him to at least get some benchmark.

See https://github.com/twpayne/xcscore-js/blob/master/README.md

More sophisticated algorithms are used for scoring real GPS tracklogs with tens of thousands of points. Contact the author for details.