Skip to content

Reduced unnecessary high swap number#61

Open
SheikhWalter wants to merge 1 commit intoSpu7Nix:mainfrom
SheikhWalter:slight-optimizations
Open

Reduced unnecessary high swap number#61
SheikhWalter wants to merge 1 commit intoSpu7Nix:mainfrom
SheikhWalter:slight-optimizations

Conversation

@SheikhWalter
Copy link

I was looking in this project trying to understand how the code works for a personal project, and in my version I needed every single slight optimization I could do -It's a computer vision project-.
So I started tweaking with the parameters, and then I saw const SWAPS_PER_GENERATION_PER_PIXEL: usize = 128;.
I tried lowering it thinking it would improve the algorithm more with the tradeoff of the accuracy, but I was half correct..
Yes the performance was improved, but here's the thing.. the accuracy barely changed!
Then I added a widget to display the processing time to test even further.

And here are my test results:

  • Best value: const SWAPS_PER_GENERATION_PER_PIXEL: usize = 8;
  • Higher than 8: it becomes slower because of the number itself
  • Lower than 8: it becomes slower too but because the assignments vector updates each iteration -necessary for dynamic image display-

If you want to see comparisons proving my point, here you go:

  • SWAPS_PER_GENERATION_PER_PIXEL = 128 (Resolution = 128) Took 4.671s
  • SWAPS_PER_GENERATION_PER_PIXEL = 8 (Resolution = 128) Took 1.972s

Notice how it now runs much faster while maintaining almost the same output

  • SWAPS_PER_GENERATION_PER_PIXEL = 4 (Resolution = 128) Took 2.164s

Now it began to run slower (assignment vector update overhead)

  • SWAPS_PER_GENERATION_PER_PIXEL = 2 (Resolution = 128) Took 2.737s

I made the same test with Resolution = 256, you can look at it in the Tests folder

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

Successfully merging this pull request may close these issues.

1 participant