Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bundle size #1

Open
mattdesl opened this issue Oct 4, 2015 · 4 comments
Open

bundle size #1

mattdesl opened this issue Oct 4, 2015 · 4 comments

Comments

@mattdesl
Copy link
Owner

mattdesl commented Oct 4, 2015

The bundle size is fairly large (101kb).

Biggest dependencies:

  • clean-pslg 81kb
  • cdt2d 15kb

Taking a look in disc, some heavy hitters are box-intersect, bn.js, and of course buffer.

/cc @mikolalysenko - what do you think?

@mikolalysenko
Copy link

box-intersect is hard to kill. Buffer is probably an accident and shouldn't be there. The tough one is bn.js, which might be removable with some work. What we really need is a modular bignumber. Perhaps this could be part of rat-nest?

@mattdesl
Copy link
Owner Author

mattdesl commented Oct 4, 2015

The size isn't a huge deal, but might turn some people off using it for frontend purposes.

Buffer is from typedarray-pool I think. Maybe also some other modules are using it?

@mattdesl
Copy link
Owner Author

mattdesl commented Oct 4, 2015

p.s. How do you usually go about unit testing triangulation modules?

@mikolalysenko
Copy link

Well, cdt2d and the other pslg type modules are a bit rough right now. I wrote that whole suite of modules in one shot during an 18 hour plane ride to Dublin, and I haven't revisited them in more detail yet.

The most important thing with geometry programming is to get the basics 100% first before jumping into more complicated stuff. For anything like triangulation, you should not be using raw inexact floating point arithmetic, unless you are ready to bear the pain later on. Using correct and robust predicates means that you can be very certain that you've caught all the logic bugs in a higher level routine using more basic unit testing practices like code coverage and fuzzing.

For writing test cases, I try to look for degeneracies and test those first. These are usually things like denormal numbers, overflows, rounding bugs, or input which is not in general position. So things which are usually good test for triangulation specifically are:

  • Arrangements of cocircular/collinear points
  • Vertical and horizontal lines
  • Points which are very close to the origin (denormalized)
  • Points which are very far away from the origin
  • Points which are almost collinear/cocircular
  • Any combination of the above

It is also important to test the performance of a module too. It is very easy in JavaScript to write code that works, but might not have good asymptotic performance due to stupid things like array splicing or string copying. So you usually need to run some experiments with inputs over a parameter sweep and then test that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants