Author Topic: Auto Optimization Program  (Read 49392 times)

0 Members and 2 Guests are viewing this topic.

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Auto Optimization Program
« Reply #15 on: September 01, 2010, 06:46:07 pm »
Ah, ya. Hmmm, what you could do is maybe have it some how check how many tokens are used and then after and put which ever is more efficient or something. I don't know, but good luck :D

@Deep Thought
It's actually probably about a 50-50 chance that the shorter one will be smaller or larger, I think anyways. I mean until Builder just gave that example I had never seen one that wasn't smaller.
« Last Edit: September 01, 2010, 06:48:07 pm by meishe91 »
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Auto Optimization Program
« Reply #16 on: September 01, 2010, 06:47:33 pm »
Yep, good luck. And another optimization idea: removing =0 from If statements (doesn't always work, though, so it should count the number of parentheses as well).




Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Auto Optimization Program
« Reply #17 on: September 01, 2010, 06:51:37 pm »
you mean =1?  I already have plans for optimizing =0 into not(, but like you said, i will need some expressions detection.  As for expansion, it doesn't seem to be *to* beneficial on average, so im going to leave it out for now.  But i might put it in later.  Also im doing the easy stuff first :P

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Auto Optimization Program
« Reply #18 on: September 01, 2010, 06:53:47 pm »
you mean =1?  I already have plans for optimizing =0 into not(, but like you said, i will need some expressions detection.  As for expansion, it doesn't seem to be *to* beneficial on average, so im going to leave it out for now.  But i might put it in later.  Also im doing the easy stuff first :P

Whoops, typo.

Also, remember to delete ending braces and brackets as well.




Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Auto Optimization Program
« Reply #19 on: September 01, 2010, 06:54:54 pm »
ah yes, good catch :)

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Auto Optimization Program
« Reply #20 on: September 01, 2010, 06:59:14 pm »
Does your program recognize closed strings already? Like for "Hello, worl"+sub("abcde",4,1) would it take off the last parenthesis? Just in case :)




Offline guy6020665

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 481
  • Rating: +7/-1
    • View Profile
Re: Auto Optimization Program
« Reply #21 on: September 01, 2010, 07:01:04 pm »
This is pretty cool!  :) Will it possibly be able to auto optimize Axe programs too?

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Auto Optimization Program
« Reply #22 on: September 01, 2010, 07:02:48 pm »
Axe sources don't need to be optimized like BASIC programs, since all that matters is the executable anyway, and optimizing the source to make the executable smaller would probably be extremely hard.




Offline KermMartian

  • Editor
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 500
  • Rating: +233/-20
    • View Profile
    • Cemetech
Re: Auto Optimization Program
« Reply #23 on: September 01, 2010, 07:03:57 pm »
So i was inspired by SourceCoders' broken Basic Optimizer function, and i thought about making one on the calculator, so you could optimize your Basic Programs without having to transfer them to the computer for any utility.  I quickly wrote up some code in Axe, and the optimizations have started :)  Currently it has support for:

Ending Parenthasis
Ending Quotes
Devlar

And there is plans and psedocode for

Implied multiplication
=0 into Not(
Powers of 10
Negative/Positive cancellation

any other ideas of simple find and replace optimizations that i could put into the optimizer?  Obviously i cant do some of the complicated stuff, but there are some good simple replacements that can make a big difference.  And note that it ignores Strings completely :) Strings Should not be changed ^^.  And there also might be an option on whether to erase empty lines or not.  Some people like to keep them for readability during development, and then maybe want to take them out later.
Might I request that you crosspost this to Cemetech, both so we can discuss this idea, and moreover that we can talk about you helping me improve SourceCoder's optimizations? I can't fix it if people don't tell me to my face that they're unhappy about a feature.



Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Auto Optimization Program
« Reply #24 on: September 01, 2010, 07:22:37 pm »
I thought that was hiding under the carpet though :P thats why i was asking about bug reports.  Either way, i didnt start this because im dissatisfied with Sourcecoder, i just was inspired by it.  Also where should i put my post, in projects or Sourcecoder?

And yeah Deep Thought, it recognizes that the last token is not part of a string and so it removes it :)

There are some simple axe optimizations that could be done, but they are few, i'd have to work with axe a lot more until i am as comfortable in it as i am in Ti Basic.

Offline KermMartian

  • Editor
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 500
  • Rating: +233/-20
    • View Profile
    • Cemetech
Re: Auto Optimization Program
« Reply #25 on: September 01, 2010, 07:26:18 pm »
I thought that was hiding under the carpet though :P thats why i was asking about bug reports.  Either way, i didnt start this because im dissatisfied with Sourcecoder, i just was inspired by it.  Also where should i put my post, in projects or Sourcecoder?

And yeah Deep Thought, it recognizes that the last token is not part of a string and so it removes it :)

There are some simple axe optimizations that could be done, but they are few, i'd have to work with axe a lot more until i am as comfortable in it as i am in Ti Basic.
Start with Projects, then we can extend it to SourceCoder as necessary. :)



Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Auto Optimization Program
« Reply #26 on: September 01, 2010, 07:31:18 pm »
Alright, its done :)

I also just had an idea for an obscure optimization:  Output(#,#,"# can be optimized to Output(#,#,# :) But only for single digit cumbers and only for Output, not Disp.  Its small and obscure but the more the merrier ;D

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Auto Optimization Program
« Reply #27 on: September 01, 2010, 07:33:37 pm »
"cumbers"? lol

And Text( too. And if you really wanted to, you could simplify obvious ones like *3*5 :D

But what about those times when people purposefully bloat their code to make it run faster?
« Last Edit: September 01, 2010, 07:33:49 pm by Deep Thought »




Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Auto Optimization Program
« Reply #28 on: September 01, 2010, 07:41:00 pm »
hmmm i dont think any of these specific optimizations will result in slower code.  Those types of optimizations are very in depth and hard to detect so i dont think i will have to worry about them.  If it does become a problem i can have it as an option :)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Auto Optimization Program
« Reply #29 on: September 04, 2010, 04:51:25 pm »
Alright ladies and gents, this is the moment you've all been waiting for!  I am releasing a beta of the Optimizer App :) Feel free to try it on all your programs and test them out to make sure i didnt break them XD Im also including the source because it has a really handy program browser built into it and that was very difficult to make.  Props to Buckey for all the help he gave me with the Vat entries! ^^

These are the codes it optimizes in this version:
Ending brackets, braces, and parentheses
Powers of 10 and other large constants
Squared and Cubed
Eliminating Empty lines
Delvar
Negative/Positive canceling

And here is a screenie of it in Action!