First off... I can't believe I spent the last 8 hours creating new designs for this programming problem....
With that out of the way, I said I had an epiphany, so here are the results:
Version 2.2 (running on my 2.4GHz work machine):
1k x 1k: 0.23s, 4.96 MB
10k x 10k: 70s, 17.1 MB
Version 2.3 (running on my 2.4GHz work machine):
1k x 1k: 0.37s, 4.93 MB
10k x 10k: 55s, 6.2 MB
20k x 20k: 6m 2s, 8.6 MB
2.2 is built for absolute maximum speed. I'm convinced it's very near optimal without going to a lower level language like C or ASM.
2.3 is with the same time saving optimizations as in 2.2, but also includes memory saving optimizations (as can be seen from the numbers). It's still a little rough, but I may touch it up tomorrow.
Tnadrev, since you're also using C#, here is the display code I use...
My version is a command line app, and I use conditional compilation to enable or disable the visual output. This first bit can be put anywhere before the algorithm start. It'll create a new window of the right size and get's it ready for painting.
Then I have the following inside the actual algorithm:
(edit) Oh yea, forgot about the includes:
That's it! Like I said before, it's only a couple lines. Try it out, it's fun to watch
(edit) oh, and about your memory size question... The working set is physical memory mapped to the process at the time of the call. If your memory usage changes over the course of the algorithm, Process.PeakWorkingSet() would get the maximum that your app used at any one time. Depending on how yours works, the working set may vary greatly over the life of the process.
With that out of the way, I said I had an epiphany, so here are the results:
Version 2.2 (running on my 2.4GHz work machine):
1k x 1k: 0.23s, 4.96 MB
10k x 10k: 70s, 17.1 MB
Version 2.3 (running on my 2.4GHz work machine):
1k x 1k: 0.37s, 4.93 MB
10k x 10k: 55s, 6.2 MB
20k x 20k: 6m 2s, 8.6 MB
2.2 is built for absolute maximum speed. I'm convinced it's very near optimal without going to a lower level language like C or ASM.
2.3 is with the same time saving optimizations as in 2.2, but also includes memory saving optimizations (as can be seen from the numbers). It's still a little rough, but I may touch it up tomorrow.
Tnadrev, since you're also using C#, here is the display code I use...
My version is a command line app, and I use conditional compilation to enable or disable the visual output. This first bit can be put anywhere before the algorithm start. It'll create a new window of the right size and get's it ready for painting.
Code:
#if(visual)
Form outForm = new Form();
outForm.Height = innerSize+27;
outForm.Width = innerSize+8;
outForm.Show();
Graphics draw = Graphics.FromHwnd(outForm.Handle);
draw.Clear(Color.White);
#endif
Code:
#if(visual)
draw.FillRectangle(Brushes.Black, x, y, 1, 1);
#endif
(edit) Oh yea, forgot about the includes:
Code:
#if(visual)
using System.Windows.Forms;
using System.Drawing;
#endif
That's it! Like I said before, it's only a couple lines. Try it out, it's fun to watch
(edit) oh, and about your memory size question... The working set is physical memory mapped to the process at the time of the call. If your memory usage changes over the course of the algorithm, Process.PeakWorkingSet() would get the maximum that your app used at any one time. Depending on how yours works, the working set may vary greatly over the life of the process.