Sha256: a75f5557583ae1d49578ae2aa7170639c5855c0065b682c633239a9881b9bd14

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

# Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

if ENV.include? 'BENCH_9000_NATIVE'
  require "oily_png/oily_png"
else
  require "chunky_png"
end

PIXEL = 0x12345678

class MockCanvas
  if ENV.include? 'BENCH_9000_NATIVE'
    include OilyPNG::Operations
  else
    include ChunkyPNG::Canvas::Operations
  end

  public :compose!

  def initialize
    @pixels = Array.new(width * height, 0)

    @pixels.size.times do |n|
      @pixels[n] = PIXEL
    end
  end

  def width
    4000
  end

  def height
    4000
  end

  def pixels
    @pixels
  end

  def get_pixel(x, y)
    @pixels[y * width + x]
  end

  def set_pixel(x, y, color)
    @pixels[y * width + x] = color
  end
end

def harness_input
  [MockCanvas.new, MockCanvas.new]
end

def harness_sample(input)
  onto, replace = input
  onto.replace!(replace, 0, 0)
  onto
end

def harness_verify(output)
  output.pixels.inject(:+) == 4886718336000000
end

require 'bench9000/harness'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bench9000-0.1 benchmarks/chunky_png/chunky-operations-replace.rb