brainfuck-c | Brainfuck interpreter in C | Interpreter library
kandi X-RAY | brainfuck-c Summary
kandi X-RAY | brainfuck-c Summary
Brainfuck-C is a Brainfuck interpreter written in C.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of brainfuck-c
brainfuck-c Key Features
brainfuck-c Examples and Code Snippets
Community Discussions
Trending Discussions on brainfuck-c
QUESTION
I have a Brainfuck interpreter project with two source files, altering the order that the source files are given as operands to Clang, and nothing else, results in consistent performance differences.
I am using Clang, with the following arguments:
clang -I../ext -D VERSION=\"1.0.0\" main.c lex.c
clang -I../ext -D VERSION=\"1.0.0\" lex.c main.c
Performance differences are seen regardless of optimisation level.
Benchmark results:
-O0
lex before main: 13.68s, main before lex: 13.02s-01
lex before main: 6.91s, main before lex: 6.65s-O2
lex before main: 7.58s, main before lex: 7.50s-O3
lex before main: 6.25s, main before lex: 7.40s
Which order performs worse is not always consistent between the optimisation levels, but for each level, the same operand order always performs worse than the other.
Notes:
- Source code can be found here.
- The mandelbrot benchmark that I am using with the interpreter can be found here.
Edits:
- The executable files for each optimisation level are exactly the same size, but are structured differently.
- Object files are identical with either operand order.
- The I/O and parsing process is indistinguishably quick regardless of operand order, even running a 500 MiB random file through it results in no variation, thus performance variation is occurring in the run loop.
- Upon comparing the objdump of each executable, it appears to me that the primary, if not the only, difference is the order of the sections (, , etc), and the memory addresses that have changed because of this.
- The objdumps can be found here.
ANSWER
Answered 2020-Jul-01 at 10:01I don't have a complete answer. But I think I know what's causing the differences between linkage ordering.
First, I got the similar results. I'm using gcc on cygwin. Some sample runs:
Building like this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install brainfuck-c
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page