Tuesday, August 21, 2012

GJSieve 1.8.* -> 1.9.0

On July 31st, I released GJSieve 1.7.0. This marked a major improvement in both computation and graphical appearance.

1.7.0 was not without its issues, and thus after a few days' rest, I began working hard on GJSieve 1.8.0.

My primary goal was to fix the way results files were printed, as well as adding some additional features. I also wanted to work on overall computation performance in one of two ways:
  • Provide indicators of performance (that is, live metrics) or
  • Actually implement changes that would reduce computation time and stress
Well, it turns out that I actually had to do both of these things.

GJSieve 1.8.0 included performance metrics that measured computation time fairly accurately as well as a prototype function for determining your CPU type and amount of physically installed memory (which on my system appears accurate enough).

GJSieve 1.8.0 was not particularly well-organized, however. I took someone's helpful advice and trimmed the giant, ~2000-line cpp file into a bunch of smaller files, each of which contains a single function - sometimes several.

For example, the window procedure LRESULT CALLBACK WinProcPROTH(...) is now in its own little cpp file. Within that, even, things needed to be trimmed down. The part of the window procedure that gives creation instructions was particularly long because of all the multi-line CreateWindowEx() functions - each of which takes 12 arguments! So, I moved everything under case WM_CREATE to another cpp file. That means that instead of this:

I have this:

I called this re-organized, easier-to-navigate version GJSieve 1.8.5. Version 1.8.0 will never be released, as it was never fully written (that is, I disabled some things and never re-enabled them!).

GJSieve 1.8.5, however, was based on and in fact written on top of the exact same Visual Studio solution I had used for every previous version of the GJSieve GUI. Yuck! 

My solution (don't pardon the pun) was to make a completely new solution and re-import everything from my personal source control, which is a folder in my Code library.

So now everything is fresh and clean and - oh yeah! - multi-threaded.

GJSieve 1.9.0 has the most changes of any version yet, including re-working the number testing into a two-button process.

The Calculate button simply determines the Proth number and prints it. The Test button actually tests it. The major difference is that the Test button runs the (newly optimized) prime-testing algorithm in a separate thread, leaving you free to do things like move the window, resize it, and click menu items and buttons without freezing the program (or simply being unable to).

This means that yes, the Panic! button now has a purpose other than simply quitting when you're done. At least on my system, you are unable to quit with the red X whilst the test is in progress, but the Panic! button will destroy the window and both GJSieve threads instantly. That means that if the test is taking too long, or it actually starts to hang, you can kill it.

GJSieve 1.9.0 is definitely still in testing, but I just thought a progress report was in order!


No comments:

Post a Comment