Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Terminal Benchmark 1.0 by CrazedProgrammer
- local t, ft, fc, ftc, st, sc, stc, native = term, " ", "f", "0", " ", "ffffffffffffffffffffffffffffffffffffffffffffffffff", "00000000000000000000000000000000000000000000000000"
- if ({...})[1] == "n" then
- t = term.native()
- native = true
- end
- t.setBackgroundColor(colors.black)
- t.setTextColor(colors.white)
- t.setCursorPos(1, 2)
- t.setCursorBlink(false)
- t.clear()
- t.write((native and "Native " or "").."Terminal Benchmark 1.0 by CrazedProgrammer")
- t.setCursorPos(1, 3)
- t.write("This will take around 1 minute.")
- os.sleep(2)
- local clock = os.clock()
- local cclock = clock
- local count = 0
- while cclock < clock + 5 do
- for i=1,1000 do
- t.clear()
- end
- count = count + 1000
- cclock = os.clock()
- end
- local dtime = cclock - clock
- local time = dtime / count
- t.setCursorPos(1, 2)
- t.write((native and "Native " or "").."Terminal Benchmark 1.0 by CrazedProgrammer")
- t.setCursorPos(1, 3)
- t.write("term.clear: " .. tostring(time * 1000000) .. " us ("..tostring(count / 1000).."k in "..tostring(dtime).." s)")
- t.setCursorPos(1, 1)
- os.sleep(0)
- clock = os.clock()
- cclock = clock
- count = 0
- while cclock < clock + 5 do
- for i=1,1000 do
- t.clearLine()
- end
- count = count + 1000
- cclock = os.clock()
- end
- dtime = cclock - clock
- time = dtime / count
- t.setCursorPos(1, 4)
- t.write("term.clearLine: " .. tostring(time * 1000000) .. " us ("..tostring(count / 1000).."k in "..tostring(dtime).." s)")
- os.sleep(0)
- clock = os.clock()
- cclock = clock
- count = 0
- while cclock < clock + 5 do
- for i=1,1000 do
- t.setCursorPos(1, 1)
- end
- count = count + 1000
- cclock = os.clock()
- end
- dtime = cclock - clock
- time = dtime / count
- t.setCursorPos(1, 5)
- t.write("term.setCursorPos: " .. tostring(time * 1000000) .. " us ("..tostring(count / 1000).."k in "..tostring(dtime).." s)")
- t.setCursorPos(1, 1)
- os.sleep(0)
- clock = os.clock()
- cclock = clock
- count = 0
- while cclock < clock + 5 do
- for i=1,1000 do
- t.setTextColor(1)
- end
- count = count + 1000
- cclock = os.clock()
- end
- dtime = cclock - clock
- time = dtime / count
- t.setCursorPos(1, 6)
- t.write("term.setTextColor: " .. tostring(time * 1000000) .. " us ("..tostring(count / 1000).."k in "..tostring(dtime).." s)")
- t.setCursorPos(1, 1)
- os.sleep(0)
- clock = os.clock()
- cclock = clock
- count = 0
- while cclock < clock + 5 do
- for i=1,1000 do
- t.setBackgroundColor(32768)
- end
- count = count + 1000
- cclock = os.clock()
- end
- dtime = cclock - clock
- time = dtime / count
- t.setCursorPos(1, 7)
- t.write("term.setBackgroundColor: " .. tostring(time * 1000000) .. " us ("..tostring(count / 1000).."k in "..tostring(dtime).." s)")
- t.setCursorPos(1, 1)
- os.sleep(0)
- clock = os.clock()
- cclock = clock
- count = 0
- while cclock < clock + 5 do
- for i=1,1000 do
- t.write(ft)
- end
- count = count + 1000
- cclock = os.clock()
- end
- dtime = cclock - clock
- time = dtime / count
- t.setCursorPos(1, 8)
- t.write("term.write 1: " .. tostring(time * 1000000) .. " us ("..tostring(count / 1000).."k in "..tostring(dtime).." s)")
- t.setCursorPos(1, 1)
- os.sleep(0)
- clock = os.clock()
- cclock = clock
- count = 0
- while cclock < clock + 5 do
- for i=1,1000 do
- t.write(st)
- end
- count = count + 1000
- cclock = os.clock()
- end
- dtime = cclock - clock
- time = dtime / count
- t.setCursorPos(1, 9)
- t.write("term.write 50: " .. tostring(time * 1000000) .. " us ("..tostring(count / 1000).."k in "..tostring(dtime).." s)")
- t.setCursorPos(1, 1)
- os.sleep(0)
- clock = os.clock()
- cclock = clock
- count = 0
- while cclock < clock + 5 do
- for i=1,1000 do
- t.blit(ft, ftc, fc)
- end
- count = count + 1000
- cclock = os.clock()
- end
- dtime = cclock - clock
- time = dtime / count
- t.setCursorPos(1, 10)
- t.write("term.blit 1: " .. tostring(time * 1000000) .. " us ("..tostring(count / 1000).."k in "..tostring(dtime).." s)")
- t.setCursorPos(1, 1)
- os.sleep(0)
- clock = os.clock()
- cclock = clock
- count = 0
- while cclock < clock + 5 do
- for i=1,1000 do
- t.blit(st, stc, sc)
- end
- count = count + 1000
- cclock = os.clock()
- end
- dtime = cclock - clock
- time = dtime / count
- t.setCursorPos(1, 11)
- t.write("term.blit 50: " .. tostring(time * 1000000) .. " us ("..tostring(count / 1000).."k in "..tostring(dtime).." s)")
- t.setCursorPos(1, 12)
- os.sleep(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement