flat assembler
Message board for the users of flat assembler.
Index
> Main > Unsure about performance test results in string printing |
Author |
|
revolution 12 Apr 2024, 16:55
The timings will be meaningless because of the overhead of many other things in the system that dwarf the thing you want to measure.
Better to start the process only once and run the loop in the process itself. |
|||
12 Apr 2024, 16:55 |
|
macomics 12 Apr 2024, 18:41
Quote: ~$ fasm test_print.asm test_print1 -d TEST_NAME=print1 -d TEST_COUNT=20000000 I don't know about you, but I have a significant difference. I did not test your code, but an algorithm similar in description. Code: format ELF64 executable 3 segment executable entry $ match =TEST_COUNT, TEST_COUNT { define TEST_COUNT 10000 } match =TEST_NAME, TEST_NAME { define TEST_NAME print0 } mov rcx, TEST_COUNT @@: push rcx lea rax, [hello_world] match name, TEST_NAME { call name } pop rcx loop @b mov rax, 60 xor dil, dil syscall print0: retn print1: push 1 pop rdi mov rsi, rax mov rax, rdi @@: cmp byte [rsi], 0 jz @f mov rax, rdi mov rdx, rdi syscall inc rsi jmp @b @@: retn print2: push 1 or rdx, -1 mov rsi, rax pop rdi @@: inc rdx cmp byte [rax + rdx], 0 jnz @b mov rax, rdi syscall retn hello_world db 'Hello world!', 10, 0 Last edited by macomics on 12 Apr 2024, 18:52; edited 1 time in total |
|||
12 Apr 2024, 18:41 |
|
revolution 12 Apr 2024, 18:48
macomics wrote: I don't know about you, but I have a significant difference. |
|||
12 Apr 2024, 18:48 |
|
macomics 12 Apr 2024, 18:55
revolution wrote: OP used the shell to launch the task repeatedly, and the task was very short, so the overhead of launching and terminating will be the major bottleneck there. Add to that the normal randomness of other processes interrupting everything and you get useless variable results. That's why I wrote my own version for testing In his version, I am at least confused by the command xor esp, esp |
|||
12 Apr 2024, 18:55 |
|
revolution 12 Apr 2024, 19:04
macomics wrote: In his version, I am at least confused by the command xor esp, esp There is another thread I posted about using ESP that way. And nothing goes wrong, it all works just fine. |
|||
12 Apr 2024, 19:04 |
|
macomics 12 Apr 2024, 20:02
revolution wrote: ESP is used as a normal register. If you don't need the stack then it is perfectly fine to do that (as long as you use an OS in protected mode, or you disable interrupts in real mode). That's not the point. In compatibility with another program. Macros are good, but they must take into account the many possibilities of using code. Besides xor esp, esp, I am also confused by @@ labels instead of named local labels. |
|||
12 Apr 2024, 20:02 |
|
Anthony S. 12 Apr 2024, 20:23
revolution wrote: The timings will be meaningless because of the overhead of many other things in the system that dwarf the thing you want to measure. Ah, I overlooked the shell acting as a bottleneck because of the loop I implemented. Thank you for pointing that out! (btw, i'm still learning assembly fundamentals so yeah, the code is a mess) _________________ In the beginning you always want the results. In the end all you want is control. |
|||
12 Apr 2024, 20:23 |
|
Anthony S. 12 Apr 2024, 20:31
macomics wrote:
Thanks for the feedback on my design choices. I mainly just messed around and tested stuff out. I checked out your test code and picked up a few tricks I hadn’t thought of before. Really helpful, thanks! _________________ In the beginning you always want the results. In the end all you want is control. |
|||
12 Apr 2024, 20:31 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.