ldc -release -O5 -mcpu=native test.d && ./test
reduce!(min,max) = 7 secs, 722 ms, 265 μs, and 4 hnsecs
fold.minMax = 5 secs, 770 ms, and 427 μs
minmaxElement = 5 secs, 410 ms, and 31 μs
minmaxElementInPairs = 15 secs, 362 ms, 724 μs, and 3 hnsecs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env dub | |
/++ dub.sdl: | |
name "filter" | |
dependency "inifiled" version="~>1.0.1" | |
dependency "dscanner" version="~>0.4.0" | |
+/ | |
import analysis.config; | |
import dparse.lexer : StringCache; | |
import dsymbol.modulecache : ModuleCache; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env rdmd | |
import std.algorithm, std.array, std.conv, std.mmfile, std.range, std.stdio, std.bigint; | |
void main(string[] args) | |
{ | |
if (args.length < 2) | |
{ | |
writeln("No input file given."); | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> dmd -release -O test.d && ./test | |
extremum.before = 54 secs, 12 ms, 347 μs, and 9 hnsecs | |
extremum.after = 29 secs, 521 ms, 896 μs, and 5 hnsecs | |
> ldc -release -O3 test.d && ./test | |
extremum.before = 13 secs, 186 ms, 176 μs, and 4 hnsecs | |
extremum.after = 2 secs, 241 ms, 454 μs, and 9 hnsecs |
- Enable the DScanner check
In the .dscanner.ini
, set the immutable check to enable
:
could_be_immutable_check="enabled"
- Generate a file with all Dscanner warnings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> ldc -O5 -release -boundscheck=off walkBack.d && ./walkBack | |
walkBack.foreach = 3 secs, 772 ms, 463 μs, and 6 hnsecs | |
walkBack.while = 4 secs, 191 ms, 417 μs, and 8 hnsecs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env rdmd | |
auto parenDiff(S)(S ss) | |
{ | |
auto count = 0; | |
foreach (s; ss) | |
{ | |
switch (s) | |
{ | |
case '(': count++; break; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> ldc -O5 -release -boundscheck=off test.d && ./test 1 2 8 256 1024 65536 | |
benchmark: 1 (bits: 1) | |
random.uniform = 742 ms, 824 μs, and 5 hnsecs | |
random.bitwise = 218 ms, 972 μs, and 9 hnsecs | |
random.uniform.fixed = 592 ms, 647 μs, and 2 hnsecs | |
benchmark: 2 (bits: 2) | |
random.uniform = 746 ms, 839 μs, and 5 hnsecs | |
random.bitwise = 497 ms and 189 μs | |
random.uniform.fixed = 594 ms, 196 μs, and 1 hnsec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.algorithm, std.conv, std.datetime, std.functional, std.range, std.stdio, std.traits, std.typecons; | |
private void doNotOptimizeAway(T)(auto ref T t) | |
{ | |
import core.thread : getpid; | |
import std.stdio : writeln; | |
if(getpid() == 1) { | |
writeln(*cast(char*)&t); | |
} | |
} |