{"action":"created","issue":{"url":"https://api.github.com/repos/samaaron/sonic-pi/issues/755","labels_url":"https://api.github.com/repos/samaaron/sonic-pi/issues/755/labels{/name}","comments_url":"https://api.github.com/repos/samaaron/sonic-pi/issues/755/comments","events_url":"https://api.github.com/repos/samaaron/sonic-pi/issues/755/events","html_url":"https://github.com/samaaron/sonic-pi/pull/755","id":113196701,"number":755,"title":"Remove string length hack during packing","user":{"login":"madgen","id":3607546,"avatar_url":"https://avatars.githubusercontent.com/u/3607546?v=3","gravatar_id":"","url":"https://api.github.com/users/madgen","html_url":"https://github.com/madgen","followers_url":"https://api.github.com/users/madgen/followers","following_url":"https://api.github.com/users/madgen/following{/other_user}","gists_url":"https://api.github.com/users/madgen/gists{/gist_id}","starred_url":"https://api.github.com/users/madgen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/madgen/subscriptions","organizations_url":"https://api.github.com/users/madgen/orgs","repos_url":"https://api.github.com/users/madgen/repos","events_url":"https://api.github.com/users/madgen/events{/privacy}","received_events_url":"https://api.github.com/users/madgen/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-10-25T00:27:51Z","updated_at":"2015-10-25T17:30:33Z","closed_at":"2015-10-25T09:41:37Z","pull_request":{"url":"https://api.github.com/repos/samaaron/sonic-pi/pulls/755","html_url":"https://github.com/samaaron/sonic-pi/pull/755","diff_url":"https://github.com/samaaron/sonic-pi/pull/755.diff","patch_url":"https://github.com/samaaron/sonic-pi/pull/755.patch"},"body":"Floating point operation is unnecessarily slow and is hacky in this\r\ncontext. This version produces the same output for each size while\r\nbeing faster.\r\n\r\nApproach with caution. Although it should behave the same, I tested\r\nonly by `rake test`.\r\n\r\nAs for the speed of the calculation:\r\n```ruby\r\nsizes = (0...1000).map {|el| rand}\r\n10000000.times { sizes << rand(10000) }\r\n\r\nBenchmark.bm do |x|\r\n  x.report(\"Bit manipulation\") do\r\n    sizes.each do |size|\r\n      size + 4 - (size % 4)\r\n    end\r\n  end\r\n\r\n  x.report(\"Floating point  \") do\r\n    sizes.each do |size|\r\n      4*((size.to_f+0.01)/4).ceil\r\n    end\r\n  end\r\nend\r\n\r\n#        user     system      total        real\r\n# Bit manipulation  0.770000   0.000000   0.770000 (  0.779492)\r\n# Floating point    1.750000   0.000000   1.750000 (  1.761073)\r\n```"},"comment":{"url":"https://api.github.com/repos/samaaron/sonic-pi/issues/comments/150946838","html_url":"https://github.com/samaaron/sonic-pi/pull/755#issuecomment-150946838","issue_url":"https://api.github.com/repos/samaaron/sonic-pi/issues/755","id":150946838,"user":{"login":"madgen","id":3607546,"avatar_url":"https://avatars.githubusercontent.com/u/3607546?v=3","gravatar_id":"","url":"https://api.github.com/users/madgen","html_url":"https://github.com/madgen","followers_url":"https://api.github.com/users/madgen/followers","following_url":"https://api.github.com/users/madgen/following{/other_user}","gists_url":"https://api.github.com/users/madgen/gists{/gist_id}","starred_url":"https://api.github.com/users/madgen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/madgen/subscriptions","organizations_url":"https://api.github.com/users/madgen/orgs","repos_url":"https://api.github.com/users/madgen/repos","events_url":"https://api.github.com/users/madgen/events{/privacy}","received_events_url":"https://api.github.com/users/madgen/received_events","type":"User","site_admin":false},"created_at":"2015-10-25T17:30:33Z","updated_at":"2015-10-25T17:30:33Z","body":"@xavriley Thanks for the comments and pointing me to the benchmark file.\r\n\r\nI can't get a reliable benchmark for with/without variable assignment. Regardless of the benchmarking duration, in some runs assignment wins, in others double dereferencing does.\r\n\r\nI am not very good at benchmarking so maybe you might like to conduct a more comprehensive test or explain me where I might be going wrong.\r\n\r\nIn either case though the iteration diff. is less than 1/100th of the total number of iterations."}}