Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS Main Plugin, MBS Images Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Main/Picture Benchmark
This example is the version from Sun, 17th Mar 2012.
Project "Picture Benchmark.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control Listbox1 Inherits Listbox
ControlInstance Listbox1 Inherits Listbox
EventHandler Function CellBackgroundPaint(g As Graphics, row As Integer, column As Integer) As Boolean
if row<me.ListCount and row <> me.ListIndex then
dim v as Variant = me.CellTag(row, column)
if VarType(v) = v.TypeColor then
dim c as color = v
g.ForeColor = c
g.FillRect 0,0,g.Width, g.Height
Return true
end if
end if
End EventHandler
EventHandler Sub Open()
me.ColumnAlignment(1) = me.AlignRight
me.ColumnAlignment(2) = me.AlignRight
End EventHandler
End Control
EventHandler Sub Open()
CheckSmallJPEGCompression
CheckSmallJPEGDecompression
CheckSmallPNGCompression
CheckSmallPNGDecompression
CheckMiddleJPEGCompression
CheckMiddleJPEGDecompression
CheckMiddlePNGCompression
CheckMiddlePNGDecompression
CheckBigJPEGCompression
CheckBigJPEGDecompression
CheckBigPNGCompression
CheckBigPNGDecompression
End EventHandler
Sub CheckBigJPEGCompression()
#pragma BackgroundTasks false
dim pic as Picture = logoMBS(2000)
listbox1.AddRow "JPEG compression big"
dim t as double = microseconds
for i as integer = 1 to 10
data = pic.GetData(pic.FormatJPEG, pic.QualityHigh)
next
t = microseconds - t
Report 2, t/10.0
t = microseconds
for i as integer = 1 to 10
data = PictureToJPEGStringMBS(pic, 80)
next
t = microseconds - t
Report 1, t/10.0
End Sub
Sub CheckBigJPEGDecompression()
#pragma BackgroundTasks false
dim pic as Picture
listbox1.AddRow "JPEG decompression big"
dim t as double = microseconds
for i as integer = 1 to 10
pic = Picture.FromData(data)
next
t = microseconds - t
Report 2, t/10.0
t = microseconds
for i as integer = 1 to 10
pic = JPEGStringToPictureMBS(data)
next
t = microseconds - t
Report 1, t/10.0
End Sub
Sub CheckBigPNGCompression()
#pragma BackgroundTasks false
dim pic as Picture = logoMBS(2000)
listbox1.AddRow "PNG compression big"
dim t as double = microseconds
for i as integer = 1 to 10
data = pic.GetData(pic.FormatPNG, pic.QualityHigh)
next
t = microseconds - t
Report 2, t/10.0
t = microseconds
for i as integer = 1 to 10
data = PictureToPNGStringMBS(pic)
next
t = microseconds - t
Report 1, t/10.0
End Sub
Sub CheckBigPNGDecompression()
#pragma BackgroundTasks false
dim pic as Picture
listbox1.AddRow "PNG decompression big"
dim t as double = microseconds
for i as integer = 1 to 10
pic = Picture.FromData(data)
next
t = microseconds - t
Report 2, t/10.0
t = microseconds
for i as integer = 1 to 10
pic = PNGStringToPictureMBS(data)
next
t = microseconds - t
Report 1, t/10.0
End Sub
Sub CheckMiddleJPEGCompression()
#pragma BackgroundTasks false
dim pic as Picture = logoMBS(500)
listbox1.AddRow "JPEG compression middle"
dim t as double = microseconds
for i as integer = 1 to 20
data = pic.GetData(pic.FormatJPEG, pic.QualityHigh)
next
t = microseconds - t
Report 2, t/20.0
t = microseconds
for i as integer = 1 to 20
data = PictureToJPEGStringMBS(pic, 80)
next
t = microseconds - t
Report 1, t/20.0
End Sub
Sub CheckMiddleJPEGDecompression()
#pragma BackgroundTasks false
dim pic as Picture
listbox1.AddRow "JPEG decompression middle"
dim t as double = microseconds
for i as integer = 1 to 20
pic = Picture.FromData(data)
next
t = microseconds - t
Report 2, t/20.0
t = microseconds
for i as integer = 1 to 20
pic = JPEGStringToPictureMBS(data)
next
t = microseconds - t
Report 1, t/20.0
End Sub
Sub CheckMiddlePNGCompression()
#pragma BackgroundTasks false
dim pic as Picture = logoMBS(500)
listbox1.AddRow "PNG compression middle"
dim t as double = microseconds
for i as integer = 1 to 20
data = pic.GetData(pic.FormatPNG, pic.QualityHigh)
next
t = microseconds - t
Report 2, t/20.0
t = microseconds
for i as integer = 1 to 20
data = PictureToPNGStringMBS(pic)
next
t = microseconds - t
Report 1, t/20.0
End Sub
Sub CheckMiddlePNGDecompression()
#pragma BackgroundTasks false
dim pic as Picture
listbox1.AddRow "PNG decompression middle"
dim t as double = microseconds
for i as integer = 1 to 20
pic = Picture.FromData(data)
next
t = microseconds - t
Report 2, t/20.0
t = microseconds
for i as integer = 1 to 20
pic = PNGStringToPictureMBS(data)
next
t = microseconds - t
Report 1, t/20.0
End Sub
Sub CheckSmallJPEGCompression()
#pragma BackgroundTasks false
dim pic as Picture = logoMBS(50)
listbox1.AddRow "JPEG compression small"
dim t as double = microseconds
for i as integer = 1 to 30
data = pic.GetData(pic.FormatJPEG, pic.QualityHigh)
next
t = microseconds - t
Report 2, t/30.0
t = microseconds
for i as integer = 1 to 30
data = PictureToJPEGStringMBS(pic, 80)
next
t = microseconds - t
Report 1, t/30.0
End Sub
Sub CheckSmallJPEGDecompression()
#pragma BackgroundTasks false
dim pic as Picture
listbox1.AddRow "JPEG decompression small"
dim t as double = microseconds
for i as integer = 1 to 30
pic = Picture.FromData(data)
next
t = microseconds - t
Report 2, t/30.0
t = microseconds
for i as integer = 1 to 30
pic = JPEGStringToPictureMBS(data)
next
t = microseconds - t
Report 1, t/30.0
End Sub
Sub CheckSmallPNGCompression()
#pragma BackgroundTasks false
dim pic as Picture = logoMBS(50)
listbox1.AddRow "PNG compression small"
dim t as double = microseconds
for i as integer = 1 to 30
data = pic.GetData(pic.FormatPNG, pic.QualityHigh)
next
t = microseconds - t
Report 2, t/30.0
t = microseconds
for i as integer = 1 to 30
data = PictureToPNGStringMBS(pic)
next
t = microseconds - t
Report 1, t/30.0
End Sub
Sub CheckSmallPNGDecompression()
#pragma BackgroundTasks false
dim pic as Picture
listbox1.AddRow "PNG decompression small"
dim t as double = microseconds
for i as integer = 1 to 30
pic = Picture.FromData(data)
next
t = microseconds - t
Report 2, t/30.0
t = microseconds
for i as integer = 1 to 30
pic = PNGStringToPictureMBS(data)
next
t = microseconds - t
Report 1, t/30.0
End Sub
Sub Report(n as integer, d as Double)
Listbox1.cell(Listbox1.LastIndex, n) = Format(d / 1000000, "0.000000")+" s"
if n = 1 then
if d<x then
Listbox1.celltag(Listbox1.LastIndex, 1) = &cCCFFCC
else
Listbox1.celltag(Listbox1.LastIndex, 1) = &cFFCCFF
end if
else
x = d
end if
End Sub
Property data As string
Property x As double
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project
The items on this page are in the following plugins: MBS Main Plugin.