Just another PureBasic Optimizer (v2.01)

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
Deeem2031
Enthusiast
Enthusiast
Posts: 216
Joined: Sat Sep 20, 2003 3:57 pm
Location: Germany
Contact:

Just another PureBasic Optimizer (v2.01)

Post by Deeem2031 »

This is the first Optimizer for PB 4.0 - and it's the first project written in PB.Net! :)
(So u need the .Net Framework 2.0+ to use the .Net exe.)

Optimizations:
-remove unused code after 'JMP' (Version 1.0)
-replace SYS_StringEqual (Ecx = 0) (Version 1.0)
-remove useless PUSH/POP (Version 1.0)

Installation:
-rename: "\Compilers\Fasm.exe" -> "\Compilers\Fasm2.exe"
-downloaden & decompress into "\Compilers\" directory:
-.Net: http://www.deeem2031.de/PB.Net/D_Optimizer_Net.zip
-x86: http://www.deeem2031.de/PB.Net/D_Optimizer_x86.zip
-ready to use

Little example:

Code: Select all

Procedure p() 
  ProcedureReturn #True 
EndProcedure 


Dim a(10,10) 

#r = 50000000 
t1 = ElapsedMilliseconds() 
For i = 1 To #r 
  If a.s 
  EndIf 
  p() 
  a(1,2) + 1 
Next 
t1 = ElapsedMilliseconds() - t1 
MessageRequester("",Str(t1))
My results:
without optimization: 2700 ms
with optimization: 725 ms
Last edited by Deeem2031 on Mon Dec 11, 2006 10:22 pm, edited 1 time in total.
irc://irc.freenode.org/#purebasic
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Post by dell_jockey »

do you really expect me to install a .NET framework for a what essentially is a peephole optimizer that tackles only three code patterns?
Come on... that's not funny at all.... :shock:
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
User avatar
Deeem2031
Enthusiast
Enthusiast
Posts: 216
Joined: Sat Sep 20, 2003 3:57 pm
Location: Germany
Contact:

Post by Deeem2031 »

Couldn't it be that u installed the Framework before?
irc://irc.freenode.org/#purebasic
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Deeem2031 wrote:Couldn't it be that u installed the Framework before?
There are quite a few of us who like PureBasic just because we can avoid .net by using it instead of some other basic :D

cheers
Tipperton
Addict
Addict
Posts: 1286
Joined: Thu Jun 19, 2003 7:55 pm

Post by Tipperton »

rsts wrote:There are quite a few of us who like PureBasic just because we can avoid .net by using it instead of some other basic :D
Amen! :mrgreen:
Heathen
Enthusiast
Enthusiast
Posts: 498
Joined: Tue Sep 27, 2005 6:54 pm
Location: At my pc coding..

Post by Heathen »

Pb.net.....:(
I love Purebasic.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Just another PureBasic Optimizer (v2.0)

Post by PB »

No offense, but your example isn't very impressive, and isn't a real-world test.
A procedure that returns #True and does nothing else? An If/EndIf that does
nothing as well? As Shania Twain sang: "That don't impress me much". ;)

So, how about a real-world example that shows the optimizations better?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Post by dell_jockey »

Deeem2031 wrote:Couldn't it be that u installed the Framework before?
Nope... am I the last one without dot net?
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Re: Just another PureBasic Optimizer (v2.0)

Post by dell_jockey »

PB wrote:No offense, but your example isn't very impressive, and isn't a real-world test.
A procedure that returns #True and does nothing else? An If/EndIf that does
nothing as well? As Shania Twain sang: "That don't impress me much". ;)

So, how about a real-world example that shows the optimizations better?
The peephole optimizers I knew in the good old days that I was still subscribed to DDJ handled 20+ code patterns. Handling just three patterns can only be called a good start.

Another point to elaborate on my initial reaction: keeping the peephole optimizer code free from framework constraints would allow us to also optimize x86 output of Linux assemblers...

Deem wrote that the optimizer code would be PB4 compatible, so there's no need for dependencies that serve no purpose. Then again, there's a Redmond company making a living with policies like this one...
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
User avatar
yoxola
Enthusiast
Enthusiast
Posts: 386
Joined: Sat Feb 25, 2006 4:23 pm

Post by yoxola »

No offensive, yet I think these procedures can be coded with PB.

In some case .NET is required, but some common tasks can be done with pure PE compiler like PB.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

[flame on]

PB .net ... I thought it was a joke, really! :shock:

Next what PBbeans? P Sharp ? PBasic (jk) ?

[flame off]

Never the less it's interesting to see Purebasic interacting with other programing languages. I give you an A for the work involved !

:lol:
JCV
Enthusiast
Enthusiast
Posts: 580
Joined: Fri Jun 30, 2006 4:30 pm
Location: Philippines

Post by JCV »

Can you just convert to pb or compile without .Net? Or any versions without using .net?
Tipperton
Addict
Addict
Posts: 1286
Joined: Thu Jun 19, 2003 7:55 pm

Post by Tipperton »

dell_jockey wrote:Nope... am I the last one without dot net?
No you're not, I still don't have .NET installed on my system... :mrgreen:
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Tipperton wrote:
dell_jockey wrote:Nope... am I the last one without dot net?
No you're not, I still don't have .NET installed on my system... :mrgreen:
Same here :D
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: Just another PureBasic Optimizer (v2.0)

Post by traumatic »

Just to throw in my 2 ct. (feel free to flame me), I think the comments
made so far are pretty unfair.

As I understand Deeem's post, it's mostly about showing the first
project ever written in PB.Net - as some kind of prove of concept.
AFAIK a lot of people are pretty excited about PB.Net becoming reality.

Don't like .NET? Fine! No one forces you to use it (as long as you don't
want to upgrade to Vista that is) - still that doesn't lower Deeem's efforts.

As initially stated, just my 2ct.
Good programmers don't comment their code. It was hard to write, should be hard to read.
Post Reply