<commit_before>
# test 4.8 million pixel writes or reads
# remove "win[x,y] = c" to benchmark empty "times" loop
# remove " = c" to benchmark pixel reads (which creates [r,g,b,a] arrays)

require "RUDL"
include RUDL
include Constant

win = DisplaySurface.new([300,200])

# create variables in advance
c = x = y = nil
start = now = totaltime = 0

10.times do
    for c in [[128,128,128],[128,128,160],[128,160,128],[128,160,160],[160,128,128],[160,128,160],[160,160,128],[160,160,160]] do
        start = Timer.ticks
        win.h.times do |y|
            win.w.times do |x|
                win[x,y] = c
            end
        end
        now = Timer.ticks
        totaltime += now - start
        win.update
        EventQueue.pump
    end
end

win.print [5,5], "4.8 million pixels, #{totaltime} ms", [255,255,255]
win.update

loop do
    ev = EventQueue.wait
    break if ev.is_a? QuitEvent
end
<commit_msg>Made it possible to abort by closing the window<commit_after>
# test 4.8 million pixel writes or reads
# remove "win[x,y] = c" to benchmark empty "times" loop
# remove " = c" to benchmark pixel reads (which creates [r,g,b,a] arrays)

require "RUDL"
include RUDL
include Constant

win = DisplaySurface.new([300,200])

# create variables in advance
c = x = y = nil
start = now = totaltime = 0

10.times do
    for c in [[128,128,128],[128,128,160],[128,160,128],[128,160,160],[160,128,128],[160,128,160],[160,160,128],[160,160,160]] do
        start = Timer.ticks
        win.h.times do |y|
            win.w.times do |x|
                win[x,y] = c
            end
        end
        now = Timer.ticks
        totaltime += now - start
        win.update
        EventQueue.get.each do |ev|
            exit if ev.is_a? QuitEvent
        end
    end
end

win.print [5,5], "4.8 million pixels, #{totaltime} ms", [255,255,255]
win.update

loop do
    ev = EventQueue.wait
    break if ev.is_a? QuitEvent
end

{'fraction_non_alphanumeric': 0.1342036553524804, 'fraction_numerical': 0.10026109660574413, 'mean_word_length': 2.601503759398496, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '804670', 'n_tokens_mistral': 815, 'n_tokens_neox': 663, 'n_words': 199}