Array fill performance differences between for, foreach, slice

data pulverizer data.pulverizer at gmail.com
Wed Apr 8 18:02:19 UTC 2020


In all honesty till now I haven't really thought deeply about 
memory allocation, I just assumed that malloc, free, and so on 
where low level operating system functions and that was that. 
I've heard people in the D community talk about garbage 
collection, and memory allocation but I didn't think it was 
something I had to worry about.

A lot of the work I do is statistics and data science based, 
often speed is important, calculations on arrays involve a lot of 
array instantiation, moving and copying elements and so forth. As 
far as all that stuff goes the speed of memory operations is 
important. The fact that I could get those kinds of operations to 
run faster using D's GC.malloc and different types of iteration 
is significant. Today it hit me that I actually need to study 
memory allocation and possibly garbage collection as topics - not 
so that I can implement a garbage collector, but so that I can 
write faster code.

I know to everyone here that's just basic stuff, but it's a bit 
of a revelation for me. :-)



More information about the Digitalmars-d-learn mailing list