Advertisement
CrazedProgrammer

Terminal Benchmark

Feb 20th, 2016
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.23 KB | None | 0 0
  1. -- Terminal Benchmark 1.0 by CrazedProgrammer
  2.  
  3. local t, ft, fc, ftc, st, sc, stc, native = term, " ", "f", "0", "                                                  ", "ffffffffffffffffffffffffffffffffffffffffffffffffff", "00000000000000000000000000000000000000000000000000"
  4. if ({...})[1] == "n" then
  5.     t = term.native()
  6.     native = true
  7. end
  8. t.setBackgroundColor(colors.black)
  9. t.setTextColor(colors.white)
  10. t.setCursorPos(1, 2)
  11. t.setCursorBlink(false)
  12. t.clear()
  13. t.write((native and "Native " or "").."Terminal Benchmark 1.0 by CrazedProgrammer")
  14. t.setCursorPos(1, 3)
  15. t.write("This will take around 1 minute.")
  16. os.sleep(2)
  17. local clock = os.clock()
  18. local cclock = clock
  19. local count = 0
  20. while cclock < clock + 5 do
  21.     for i=1,1000 do
  22.         t.clear()
  23.     end
  24.     count = count + 1000
  25.     cclock = os.clock()
  26. end
  27. local dtime = cclock - clock
  28. local time = dtime / count
  29. t.setCursorPos(1, 2)
  30. t.write((native and "Native " or "").."Terminal Benchmark 1.0 by CrazedProgrammer")
  31. t.setCursorPos(1, 3)
  32. t.write("term.clear: " .. tostring(time * 1000000) .. " us ("..tostring(count / 1000).."k in "..tostring(dtime).." s)")
  33. t.setCursorPos(1, 1)
  34. os.sleep(0)
  35. clock = os.clock()
  36. cclock = clock
  37. count = 0
  38. while cclock < clock + 5 do
  39.     for i=1,1000 do
  40.         t.clearLine()
  41.     end
  42.     count = count + 1000
  43.     cclock = os.clock()
  44. end
  45. dtime = cclock - clock
  46. time = dtime / count
  47. t.setCursorPos(1, 4)
  48. t.write("term.clearLine: " .. tostring(time * 1000000) .. " us ("..tostring(count / 1000).."k in "..tostring(dtime).." s)")
  49. os.sleep(0)
  50. clock = os.clock()
  51. cclock = clock
  52. count = 0
  53. while cclock < clock + 5 do
  54.     for i=1,1000 do
  55.         t.setCursorPos(1, 1)
  56.     end
  57.     count = count + 1000
  58.     cclock = os.clock()
  59. end
  60. dtime = cclock - clock
  61. time = dtime / count
  62. t.setCursorPos(1, 5)
  63. t.write("term.setCursorPos: " .. tostring(time * 1000000) .. " us ("..tostring(count / 1000).."k in "..tostring(dtime).." s)")
  64. t.setCursorPos(1, 1)
  65. os.sleep(0)
  66. clock = os.clock()
  67. cclock = clock
  68. count = 0
  69. while cclock < clock + 5 do
  70.     for i=1,1000 do
  71.         t.setTextColor(1)
  72.     end
  73.     count = count + 1000
  74.     cclock = os.clock()
  75. end
  76. dtime = cclock - clock
  77. time = dtime / count
  78. t.setCursorPos(1, 6)
  79. t.write("term.setTextColor: " .. tostring(time * 1000000) .. " us ("..tostring(count / 1000).."k in "..tostring(dtime).." s)")
  80. t.setCursorPos(1, 1)
  81. os.sleep(0)
  82. clock = os.clock()
  83. cclock = clock
  84. count = 0
  85. while cclock < clock + 5 do
  86.     for i=1,1000 do
  87.         t.setBackgroundColor(32768)
  88.     end
  89.     count = count + 1000
  90.     cclock = os.clock()
  91. end
  92. dtime = cclock - clock
  93. time = dtime / count
  94. t.setCursorPos(1, 7)
  95. t.write("term.setBackgroundColor: " .. tostring(time * 1000000) .. " us ("..tostring(count / 1000).."k in "..tostring(dtime).." s)")
  96. t.setCursorPos(1, 1)
  97. os.sleep(0)
  98. clock = os.clock()
  99. cclock = clock
  100. count = 0
  101. while cclock < clock + 5 do
  102.     for i=1,1000 do
  103.         t.write(ft)
  104.     end
  105.     count = count + 1000
  106.     cclock = os.clock()
  107. end
  108. dtime = cclock - clock
  109. time = dtime / count
  110. t.setCursorPos(1, 8)
  111. t.write("term.write 1: " .. tostring(time * 1000000) .. " us ("..tostring(count / 1000).."k in "..tostring(dtime).." s)")
  112. t.setCursorPos(1, 1)
  113. os.sleep(0)
  114. clock = os.clock()
  115. cclock = clock
  116. count = 0
  117. while cclock < clock + 5 do
  118.     for i=1,1000 do
  119.         t.write(st)
  120.     end
  121.     count = count + 1000
  122.     cclock = os.clock()
  123. end
  124. dtime = cclock - clock
  125. time = dtime / count
  126. t.setCursorPos(1, 9)
  127. t.write("term.write 50: " .. tostring(time * 1000000) .. " us ("..tostring(count / 1000).."k in "..tostring(dtime).." s)")
  128. t.setCursorPos(1, 1)
  129. os.sleep(0)
  130. clock = os.clock()
  131. cclock = clock
  132. count = 0
  133. while cclock < clock + 5 do
  134.     for i=1,1000 do
  135.         t.blit(ft, ftc, fc)
  136.     end
  137.     count = count + 1000
  138.     cclock = os.clock()
  139. end
  140. dtime = cclock - clock
  141. time = dtime / count
  142. t.setCursorPos(1, 10)
  143. t.write("term.blit 1: " .. tostring(time * 1000000) .. " us ("..tostring(count / 1000).."k in "..tostring(dtime).." s)")
  144. t.setCursorPos(1, 1)
  145. os.sleep(0)
  146. clock = os.clock()
  147. cclock = clock
  148. count = 0
  149. while cclock < clock + 5 do
  150.     for i=1,1000 do
  151.         t.blit(st, stc, sc)
  152.     end
  153.     count = count + 1000
  154.     cclock = os.clock()
  155. end
  156. dtime = cclock - clock
  157. time = dtime / count
  158. t.setCursorPos(1, 11)
  159. t.write("term.blit 50: " .. tostring(time * 1000000) .. " us ("..tostring(count / 1000).."k in "..tostring(dtime).." s)")
  160. t.setCursorPos(1, 12)
  161. os.sleep(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement