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

Code optimization: 30% speedup #6

Merged
merged 20 commits into from Aug 13, 2011
Merged

Code optimization: 30% speedup #6

merged 20 commits into from Aug 13, 2011

Commits on Aug 13, 2011

  1. Configuration menu
    Copy the full SHA
    a5045f4 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    85679c2 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    6e3da6d View commit details
    Browse the repository at this point in the history
  4. Better error reporting

    gioele committed Aug 13, 2011
    Configuration menu
    Copy the full SHA
    cc08a17 View commit details
    Browse the repository at this point in the history
  5. Make sure level is a Symbol

    gioele committed Aug 13, 2011
    Configuration menu
    Copy the full SHA
    1216a92 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    0fa9eab View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    65cebad View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    fad9406 View commit details
    Browse the repository at this point in the history
  9. Do not sum only to subtract

    gioele committed Aug 13, 2011
    Configuration menu
    Copy the full SHA
    a19cea7 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    2d012c8 View commit details
    Browse the repository at this point in the history
  11. Use pre-made Procs instead of long case/when construct

    Code such as
    
    	case mask_pattern
    	when QRMASKPATTERN[:pattern000]
    		(i + j) % 2 == 0
    	when QRMASKPATTERN[:pattern001]
    		i % 2 == 0
    	when QRMASKPATTERN[:pattern010]
    		j % 3 == 0
    
    is very slow because it requires an `Hash#[]` lookup and a `Kernel#===`
    call for every branch of the `case` construct, 3.5 * 2 function calls on
    average.
    
    We exploit the fact that `mask_pattern` is a Fixnum and pre-populate an
    array of possible computations. This takes exactly one `Array#[]`
    lookup and `Proc#call` execution per mask pattern.
    gioele committed Aug 13, 2011
    Configuration menu
    Copy the full SHA
    293580b View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    5eabc76 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    9b7fa53 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    84ff757 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    ab7e5dc View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    1c42501 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    06ccf4a View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    37b014b View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    f56c29a View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    52c9caf View commit details
    Browse the repository at this point in the history