1. 07 Mar, 2018 1 commit
  2. 09 Feb, 2018 1 commit
  3. 22 Nov, 2017 1 commit
  4. 06 Apr, 2017 1 commit
  5. 14 Mar, 2017 1 commit
  6. 17 Jan, 2017 1 commit
  7. 16 Jan, 2017 1 commit
  8. 14 Dec, 2016 1 commit
  9. 09 Dec, 2016 2 commits
  10. 08 Dec, 2016 1 commit
  11. 04 Oct, 2016 2 commits
  12. 03 Aug, 2016 1 commit
    • Yorick Peterse's avatar
      Improve performance of SyntaxHighlightFilter · 038d6feb
      Yorick Peterse authored
      By using Rouge::Lexer.find instead of find_fancy() and memoizing the
      HTML formatter we can speed up the highlighting process by between 1.7
      and 1.8 times (at least when measured using synthetic benchmarks). To
      measure this I used the following benchmark:
      
          require 'benchmark/ips'
      
          input = ''
      
          Dir['./app/controllers/**/*.rb'].each do |controller|
            input << <<-EOF
            <pre><code class="ruby">#{File.read(controller).strip}</code></pre>
      
            EOF
          end
      
          document = Nokogiri::HTML.fragment(input)
          filter = Banzai::Filter::SyntaxHighlightFilter.new(document)
      
          puts "Input size: #{(input.bytesize.to_f / 1024).round(2)} KB"
      
          Benchmark.ips do |bench|
            bench.report 'call' do
              filter.call
            end
          end
      
      This benchmark produces 250 KB of input. Before these changes the timing
      output would be as follows:
      
          Calculating -------------------------------------
                          call     1.000  i/100ms
          -------------------------------------------------
                          call     22.439  (±35.7%) i/s -     93.000
      
      After these changes the output instead is as follows:
      
      Calculating -------------------------------------
                      call     1.000  i/100ms
      -------------------------------------------------
                      call     41.283  (±38.8%) i/s -    148.000
      
      Note that due to the fairly high standard deviation and this being a
      synthetic benchmark it's entirely possible the real-world improvements
      are smaller.
      038d6feb
  13. 16 Jul, 2016 1 commit
  14. 15 Jul, 2016 1 commit
  15. 14 Jul, 2016 4 commits
  16. 01 Jul, 2016 1 commit
  17. 24 Mar, 2016 1 commit
  18. 14 Jan, 2016 1 commit
  19. 15 Dec, 2015 1 commit
  20. 19 Nov, 2015 1 commit
  21. 10 Sep, 2015 2 commits
  22. 28 Aug, 2015 1 commit
  23. 27 Aug, 2015 1 commit