flat assembler
Message board for the users of flat assembler.

Index > Main > STDIN/STDOUT to/from memory buffer; Battle FASM vs C++

Goto page Previous  1, 2, 3, 4
Author
Thread Post new topic Reply to topic
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
Enko wrote:
I thought the main idea behind the HLL is to produce application faster. So if for the HLL programer it taked more time to produce the same result.....
Shouldn't it be the other way, write asm to optimize the speed of HLL. Not read ASM source to produce faster HLL program.


Well, this is the common opinion. But the experiment revealed another story. At first, my first version was released prior to his first version:

Me: start: 01.05.2012; first version: 04.05.2012
Dvader: start: 01.05.2012; first version: 05.05.2012

Of course it is hard to compute the exact time consumed for this first version, but as long as both of us must work and to have some sleep, IMHO the hours per day spend for the battle programming are pretty equal.

At second, to this moment my program have speed gain maximum 2 times. This means, the first version, even written in a hurry, was pretty well optimized.
Dvader's speed improvement is more than 50 times, so his first version was pretty low quality.

At third: The only portable program in this battle is mine.
I always release versions for Win32 and Linux.
Dvaders version is only for Windows and I am not sure how fast he can compile it for Linux.

So, where are the advantages of the HLL programming?

_________________
Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9
Post 10 May 2012, 10:41
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
Another round of the battle ended. My opponent left the OOP off and turned to the linear C-like dirty code with static inline functions (I am not sure about the proper C terminology): here you can read the source
My code, on the other hand, became streamlined, faster and smaller. Wink
The Windows executable is now only 2560bytes.
The benchmark demonstrates the rough power of assembly:
Code:
ptime --r12 --alh "cmd /c markdown < test.md > test.html"
time: elapsed: 2781ms, kernel: 31ms, user: 6ms

ptime --r12 --alh "cmd /c MarkdownVader_11_05_2012 < test.md > test2.html"
time: elapsed: 4868ms, kernel: 60ms, user: 12ms    

For comparison, on the same computer, "copy test.md test2.md" takes 2000ms.
Post 11 May 2012, 17:08
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Enko



Joined: 03 Apr 2007
Posts: 678
Location: Mar del Plata
Enko
My knowledge of c/cpp is very limited. But as I remember, "templetes" are just another aproach of OOP. (like the STL)

For "static" and "static inline" no idea of the benefit. They are directives I think for the linker, but have no idea why or if they do afect the speed.

But yes, the codes looks much more like C code. I guess its the first step for optimization.
This would be the steps:

0)Write CPP Code
1)Wirte the same code but now with C
2)Write asm inline functions in the C code
3)Rewrite all the stuff in asm Laughing

By the way JohnFound, your code is more easier to read. I guess for the coments, and the labels. dvader has no comments at all.

pd: I read the thread, and actually, you to make a joke about __asm inline Laughing
Post 11 May 2012, 22:30
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.