Created
July 7, 2020 23:41
-
-
Save MCJack123/4166124e44c02208eb0bd6ca47f38bad to your computer and use it in GitHub Desktop.
CraftOS-PC rendering stress tests for character & graphics modes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local w, h = term.getSize() | |
local canBenchmark = term.benchmark ~= nil | |
local count = 0 | |
local start = os.epoch "utc" | |
if canBenchmark then term.benchmark() end | |
pcall(function() | |
while true do | |
term.setCursorPos(math.random(1, w), math.random(1, h)) | |
term.setBackgroundColor(2^math.random(0, 15)) | |
term.setTextColor(2^math.random(0, 15)) | |
term.write(string.char(math.random(0, 255))) | |
count = count + 1 | |
end | |
end) | |
local frames = canBenchmark and term.benchmark() or 0 | |
local time = os.epoch "utc" - start | |
term.setCursorPos(1, 1) | |
term.setBackgroundColor(colors.black) | |
term.setTextColor(colors.white) | |
term.clear() | |
if canBenchmark then print("Rendered " .. frames .. " frames in " .. time .. " ms (" .. (frames / (time / 1000)) .. " fps)") end | |
print("Drew " .. count .. " characters (" .. (count / (time / 1000)) .. " cps)") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
term.setGraphicsMode(2) | |
local w, h = term.getSize() | |
local canBenchmark = term.benchmark ~= nil | |
w, h = w*6-1, h*9-1 | |
for i = 0, 255 do term.setPaletteColor(i, 7 / bit32.rshift(bit32.band(i, 0xE0), 5), 7 / bit32.rshift(bit32.band(i, 0x1C), 2), 3 / bit32.band(i, 3)) end | |
local count = 0 | |
local start = os.epoch "utc" | |
if canBenchmark then term.benchmark() end | |
pcall(function() | |
while true do | |
term.setPixel(math.random(0, w), math.random(0, h), math.random(0, 255)) | |
count = count + 1 | |
end | |
end) | |
local frames = canBenchmark and term.benchmark() or 0 | |
local time = os.epoch "utc" - start | |
term.clear() | |
for i = 0, 15 do term.setPaletteColor(i, term.nativePaletteColor(2^i)) end | |
term.setGraphicsMode(0) | |
if canBenchmark then print("Rendered " .. frames .. " frames in " .. time .. " ms (" .. (frames / (time / 1000)) .. " fps)") end | |
print("Drew " .. count .. " pixels (" .. (count / (time / 1000)) .. " pps)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment