All the benchmarks have been done inaccurately/incorrectly for this. Although, its true that OSGL has certain functions that perform faster than CanvasDraw, but overall its worse than CanvasDraw. However, we can all agree OSGL is still new, and apparently there’s a lot of improvements coming.
The benchmarks that were done above were pretty much “same code”, but they hadn’t considered that CanvasDraw and OSGL have different designs in how the API, rendering, and yielding work.
After taking into consideration their designs, I had done separate tests on the same concepts for each of them, and CanvasDraw performed way better than OSGL did, at least that’s for now.
Here the result of the accurate benchmark each done according to their respective design:
~ OSGL:
23:22:06.265 Wait Time was: 0.5 - Client - Client:76
23:22:06.266 Updates Count: 10 - Client - Client:77
23:22:06.266 ALL Updates Time Taken: 11.415006999999605 - Client - Client:78
23:22:06.266 Average time taken at each generation: 0.6331923000001097 - Client - Client:88
23:22:06.353 Average FPS 1: 1.6112302991284904 - Client - Client:109
23:22:06.353 Average FPS 2: 59.40013426167859 - Client - Client:110
23:22:06.354 Average FPS 3: 59.40013425523703 - Client - Client:111
~ CanvasDraw:
23:23:18.020 Wait Time was: 0.5 - Client - LocalScript:75
23:23:18.020 Updates Count: 10 - Client - LocalScript:76
23:23:18.020 ALL Updates Time Taken: 8.308398600000146 - Client - LocalScript:77
23:23:18.020 Average time taken at each generation: 0.32490845000002083 - Client - LocalScript:87
23:23:18.109 Average FPS 1: 58.01233495249014 - Client - LocalScript:108
23:23:18.109 Average FPS 2: 58.01233495249014 - Client - LocalScript:109
23:23:18.109 Average FPS 3: 58.01233494912888 - Client - LocalScript:110
Regardless of this, OSGL still has a lot of potential, and i’m pretty sure it’s going to be great! But I’d say it’s still unfinished atm, and should be used only for testing purposes.
This is the codes for each [each done at 1024x1024 Canvas, and 500x500 Frame Size]:
- CanvasDraw Code for the benchmark:
-- Script
local UserInputService = game:GetService("UserInputService")
local finished = false
UserInputService.WindowFocusReleased:Connect(function()
if not finished then
print("WHY WINDOW RELEASED? THIS WILL MAKE IT INACCURATE")
end
end)
local Gui = script.Parent
local Frame = Gui.Frame
local CanvasDraw = require(Gui.CanvasDraw)
local rs = game:GetService("RunService")
local Canvas = CanvasDraw.new(Frame, Vector2.new(1024, 1024), Color3.new(0, 0, 0))
Canvas.AutoRender = false
wait(5)
-- FPS Counter
local RunService = game:GetService("RunService")
local fps_table = {}
local fps_table2 = {}
local fps_table3 = {}
local curfps = 0
RunService.RenderStepped:Connect(function(frametime)
curfps = 1/frametime
end)
-- Main
local c = 0
local arr = {}
local updates = 0
local waitTime = 0.5
local tt = os.clock()
while wait(waitTime) do
local t1 = os.clock()
for x = 1, 1024 do
for y = 1, 1024 do
Canvas:SetRGB(x, y, math.random(0, 1), math.random(0, 1), math.random(0, 1))
fps_table3[#fps_table3 + 1] = curfps
end
end
fps_table2[#fps_table2 + 1] = curfps
Canvas:Render()
local t = os.clock() - t1
fps_table[#fps_table + 1] = curfps
arr[#arr + 1] = t
c += 1
updates += 1
if c >= 10 then
break
end
end
local timeTakenALL = os.clock() - tt
finished = true
print("Wait Time was: " .. waitTime)
print("Updates Count: " .. updates)
print("ALL Updates Time Taken: " .. timeTakenALL)
local med = 0
-- Get average of the 10
for i = 1, #arr do
med += arr[i]
end
local avg = med / #arr
print("Average time taken at each generation: " .. avg)
local med_fps = 0
for i = 1, #fps_table do
med_fps += fps_table[i]
end
local med_fps2 = 0
for i = 1, #fps_table2 do
med_fps2 += fps_table2[i]
end
local med_fps3 = 0
for i = 1, #fps_table3 do
med_fps3 += fps_table3[i]
end
local avg_fps = med_fps / #fps_table
local avg_fps2 = med_fps2 / #fps_table2
local avg_fps3 = med_fps3 / #fps_table3
print("Average FPS 1: " .. avg_fps)
print("Average FPS 2: " .. avg_fps2)
print("Average FPS 3: " .. avg_fps3)
- OSGL Code for the benchmark:
-- Script
local UserInputService = game:GetService("UserInputService")
local finished = false
UserInputService.WindowFocusReleased:Connect(function()
if not finished then
print("WHY WINDOW RELEASED? THIS WILL MAKE IT INACCURATE")
end
end)
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local OSGL = require(ReplicatedStorage.Packages.OSGL)
local window = OSGL.Window
local color = OSGL.color
local draw = OSGL.draw
local myWindow = window.new(Players.LocalPlayer.PlayerGui:WaitForChild("Screen").Image, { sizeX = 1024, sizeY = 1024 })
wait(5)
-- FPS Counter
local RunService = game:GetService("RunService")
local fps_table = {}
local fps_table2 = {}
local fps_table3 = {}
local curfps = 0
RunService.RenderStepped:Connect(function(frametime)
curfps = 1/frametime
end)
-- Main
local c = 0
local arr = {}
local updates = 0
local waitTime = 0.5
local tt = os.clock()
while wait(waitTime) do
local t1 = os.clock()
for y = 0, 1023 do
for x = 0, 1023 do
draw.pixel(myWindow, x, y, color.new(math.random(0, 255), math.random(0, 255), math.random(0, 255), 255))
fps_table3[#fps_table3 + 1] = curfps
end
end
fps_table2[#fps_table2 + 1] = curfps
myWindow:Render()
local t = os.clock() - t1
fps_table[#fps_table + 1] = curfps
arr[#arr + 1] = t
c += 1
updates += 1
if c >= 10 then
break
end
end
local timeTakenALL = os.clock() - tt
finished = true
print("Wait Time was: " .. waitTime)
print("Updates Count: " .. updates)
print("ALL Updates Time Taken: " .. timeTakenALL)
local med = 0
-- Get average of the 10
for i = 1, #arr do
med += arr[i]
end
local avg = med / #arr
print("Average time taken at each generation: " .. avg)
local med_fps = 0
for i = 1, #fps_table do
med_fps += fps_table[i]
end
local med_fps2 = 0
for i = 1, #fps_table2 do
med_fps2 += fps_table2[i]
end
local med_fps3 = 0
for i = 1, #fps_table3 do
med_fps3 += fps_table3[i]
end
local avg_fps = med_fps / #fps_table
local avg_fps2 = med_fps2 / #fps_table2
local avg_fps3 = med_fps3 / #fps_table3
print("Average FPS 1: " .. avg_fps)
print("Average FPS 2: " .. avg_fps2)
print("Average FPS 3: " .. avg_fps3)
Wouldn’t hurt to also add Average FPS 4 before the drawing pixel, and measuring the average of how long each pixel would take to get drawn 1-4 like the FPS, but, it’s already clear, so not needed.
This is solely for the purpose of improvements, and feedback. I have nothing but respect for these guys that are working on this, and giving it away for free.
It would be great if @Ethanthegrand14 could also confirm this as I’m not the creator of CanvasDraw to have all the knowledge in it.