Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local advanced = term.isColor()
- local function setTextColor(colornum)
- if advanced then
- term.setTextColor(colornum)
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- setTextColor(colors.yellow)
- print("Computer Speed Test")
- setTextColor(colors.white)
- print("Hertz Meassurements")
- print()
- print("How many +1 Calculations done!")
- term.setCursorPos(1,6)
- local function result(name, value)
- setTextColor(colors.yellow)
- term.write(name..": ")
- setTextColor(colors.white)
- print(value)
- end
- local cycleTable = {}
- local cycleCount = 20 --Musn't be changed!
- for i = 1,cycleCount do
- clock = os.clock()
- stop = clock + (1 / cycleCount)
- local cycles = 0
- while clock < stop do
- clock = os.clock()
- cycles = cycles + 1
- end
- table.insert(cycleTable, cycles)
- end
- cycleTotal = 0
- for k, v in pairs(cycleTable) do
- cycleTotal = cycleTotal + v
- end
- function round(value, place)
- return math.floor((value / place) + 0.5) * place
- end
- cycleAverage = cycleTotal / cycleCount
- cycleAverage = round(cycleAverage, 0.01)
- hertz = cycleAverage * 20
- kilohertz = round((hertz / 1000), 0.01)
- megahertz = round((kilohertz / 1000), 0.01)
- ticks = cycleAverage
- result("Hertz",hertz)
- result("Kilohertz",kilohertz)
- result("Megahertz",megahertz)
- result("Ticks",ticks)
- print()
- setTextColor(colors.yellow)
- print("Press ENTER To Continue")
- print()
- setTextColor(colors.yellow)
- print("Raw Data (Hertz):")
- local ycount = 0
- local cursorx, cursory = term.getCursorPos()
- for k,v in pairs(cycleTable) do
- if k == 1 then ycount = cursory end
- if k == 6 then ycount = cursory end
- if k == 11 then ycount = cursory end
- if k == 16 then ycount = cursory end
- if k > 15 then
- term.setCursorPos(28,ycount)
- elseif k > 10 then
- term.setCursorPos(19,ycount)
- elseif k > 5 then
- term.setCursorPos(10,ycount)
- elseif k > 0 then
- term.setCursorPos(1,ycount)
- end
- setTextColor(colors.white) term.write(v)
- setTextColor(colors.yellow) term.write("Hz")
- ycount = ycount + 1
- end
- while true do
- event,key = os.pullEvent("key")
- if key == 28 then break end
- end
- term.clear()
- term.setCursorPos(1,1)
Advertisement
Add Comment
Please, Sign In to add comment