Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------------
- -- CPU Benchmarking Functions
- --------------------------------------------------
- function GetSystemTimeSeconds()
- local socket = require "socket"
- return socket.gettime()*1000
- end
- function CPUBenchmark()
- --This function gives the CPU some busy work to do.
- --CPU score is determined by how quickly the work is completed.
- print("test")
- local totalTime = 0
- local lastTime
- local currTime
- local countTime = 0
- --Make everything a local variable
- --This is necessary because we don't want LUA searching through the globals as part of the benchmark
- local TableInsert = table.insert
- local TableRemove = table.remove
- local h
- local i
- local j
- local k
- local l
- local m
- local n = {}
- for h = 1, 24, 1 do
- -- If the need for the benchmark no longer exists, abort it now.
- -- if not lobbyComm then
- -- return
- -- end
- lastTime = GetSystemTimeSeconds()
- -- print(lastTime)
- for i = 1.0, 30.4, 0.0008 do
- --This instruction set should cover most LUA operators
- j = i + i --Addition
- k = i * i --Multiplication
- l = k / j --Division
- m = j - i --Subtraction
- j = i ^ 4 --Power
- l = -i --Negation
- m = {'1234567890', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', true} --Create Table
- TableInsert(m, '1234567890') --Insert Table Value
- k = i < j --Less Than
- k = i == j --Equality
- k = i <= j --Less Than or Equal to
- k = not k
- n[tostring(i)] = m
- end
- currTime = GetSystemTimeSeconds()
- totalTime = totalTime + currTime - lastTime
- if totalTime > countTime then
- --This is necessary in order to make this 'thread' yield so other things can be done.
- countTime = totalTime + .125
- -- coroutine.yield(1)
- end
- end
- BenchTime = math.ceil(totalTime )
- print(BenchTime)
- return BenchTime
- end
- print(CPUBenchmark())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement