D performance guideline (request)
Unknown W. Brackets
unknown at simplemachines.org
Sat Apr 12 13:35:58 PDT 2008
There's plenty to be said, and surely that will be said. When it comes
to performance, I'm more of a server-oriented guy and I worry more about
concurrency and performance per request... I'm sure you'll get more
relevant help from others here.
I just want to suggest that, when checking performance, you make sure
you're dealing with reality. A few things that can help with that:
1. Do any file io before your benching... for example, load a file
entirely into memory, then bench/profile parsing it, executing it, etc.
2. When benchmarking, compile with -O -inline -release. You don't
really care if bounds checking, lack of inlining, etc. are slowing you
down. You care about reality.
3. In general, it's hard to get anywhere without concentrating on a
specific area of code. Find something that is slow (through profiling)
and fix it. Worry about the rest later.
4. If you destroy maintainability by optimization, you'll just pay
later. Consider how heavy the price is before you make such a move.
-[Unknown]
bobef wrote:
> Hi,
>
> I would like to request a guideline how to squeeze every last nanosecond out of D. I am writing this scripting language - FlowerScript, and I really need to take every spare bit... But the problem is... I am a noob. D performs really well, of course, but lame people like me could make even D slow :) I know here are a lot of people that are very good programmers with broad knowledge how things work and a lot of experiene, so I would like to ask you to share your experience - what to do when every tick matters. For example one could use pointers for indexing arrays, to bypass the bounds checking. Yes, it is not that pretty but gives a big boost. I am trying to experiment with things, but sometimes it is really strange. For example I have few ifs. I rearrange them a bit. Sometimes I move one if inside other and it becomes slower, sometimes I simply add curly braces and it becomes faster. Or I wrap a block of code in a try {} and it becomes faster. Why is that? If I wrap every
line of code in try, will I make it fly ? :D
>
> Thanks,
> bobef
More information about the Digitalmars-d
mailing list