nikita2007558

тпс чекер

Sep 14th, 2022
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.91 KB | None | 0 0
  1. os = require("os")
  2. term = require("term")
  3. keyboard = require("keyboard")
  4. com = require("component")
  5. term = require("term")
  6. fs = require("filesystem")
  7. w,h = com.gpu.getResolution()
  8.  
  9. crop = 0.4
  10. timeConstant = 0.1
  11.  
  12. ww = w*crop
  13. hh = h*crop
  14.  
  15. com.gpu.setResolution(ww, hh)
  16. joke = 0
  17. tSlot = 1
  18.  
  19. function time()
  20.     local f = io.open("/tmp/timeFile","w")
  21.     f:write("test")
  22.     f:close()
  23.     return(fs.lastModified("/tmp/timeFile"))
  24. end
  25.  
  26. TPS = {}
  27. avgTPS = 0
  28. for tSlot=1,10 do
  29.     TPS[tSlot]=0
  30. end
  31.  
  32. while joke < joke + 1 do
  33.     realTimeOld = time()
  34.     os.sleep(timeConstant)
  35.     realTimeNew = time()
  36.  
  37.     realTimeDiff = realTimeNew-realTimeOld
  38.  
  39.     TPS[tSlot] = 20000*timeConstant/realTimeDiff
  40.     avgTPS = (TPS[1]+TPS[2]+TPS[3]+TPS[4]+TPS[5]+TPS[6]+TPS[7]+TPS[8]+TPS[9]+TPS[10])/10
  41.  
  42.     if joke < ww then
  43.         term.clear()
  44.         com.gpu.setBackground(0x000080)
  45.         com.gpu.setForeground(0xFFFFFF)
  46.         print("roga122 tps checker\n")
  47.         com.gpu.setBackground(0x000000)
  48.         com.gpu.setForeground(0x00ff00)
  49.         com.gpu.fill(1, 7, joke, 1, '█')
  50.         com.gpu.fill(1, 8, joke, 1, '█')
  51.         com.gpu.fill(1, 9, joke, 1, '█')
  52.         com.gpu.setForeground(0xFFFFFF)
  53.  
  54.         print("TPS сейчас:", string.format("%.2f",TPS[tSlot]))
  55.         print("TPS средний:", string.format("%.2f",avgTPS))
  56.     else
  57.         term.clear()
  58.         com.gpu.setBackground(0x000080)
  59.         com.gpu.setForeground(0xFFFFFF)
  60.         print("roga122 tps checker\n")
  61.         com.gpu.setBackground(0x000000)
  62.         com.gpu.setForeground(0xFFFFFF)
  63.         print("TPS сейчас:", string.format("%.2f",TPS[tSlot]))
  64.         print("TPS средний:", string.format("%.2f",avgTPS))
  65.         joke = 0
  66.     end;
  67.     joke = joke + 1
  68.    
  69.     if tSlot == 10 then
  70.         tSlot = 0
  71.     end;
  72.    
  73.     tSlot = tSlot + 1
  74.    
  75.     print("\n\n\n\n\n\nДля выхода удерживайте\nCtrl + W\n")
  76.     if keyboard.isKeyDown(keyboard.keys.w) and keyboard.isControlDown() then
  77.         term.clear()
  78.         com.gpu.setResolution(w, h)
  79.         print("Выход...")
  80.         os.exit()
  81.     end;
  82. end;
Add Comment
Please, Sign In to add comment