Skip to content

Instantly share code, notes, and snippets.

@wilzbach
wilzbach / result
Created February 19, 2017 15:56
walkBack: use Unqual & foreach vs. checking empty twice
> 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
@wilzbach
wilzbach / How_to_run.md
Created February 20, 2017 15:34
Set possibly immutable variables in Phobos to const
  1. Enable the DScanner check

In the .dscanner.ini, set the immutable check to enable:

could_be_immutable_check="enabled"
  1. Generate a file with all Dscanner warnings
@wilzbach
wilzbach / results
Created February 28, 2017 19:01
benchmark std.algorithm.searching.extremum with and without identity specialization
> 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

With mapping

> ldc -release -O5 -mcpu=native test.d && ./test
reduce!(min,max) = 16 secs, 745 ms, 280 μs, and 1 hnsec
fold.minMax     = 13 secs, 756 ms, 979 μs, and 4 hnsecs
minmaxElement   = 14 secs, 179 ms, 390 μs, and 1 hnsec
#!/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;
@wilzbach
wilzbach / benchmark.md
Created May 5, 2017 14:56
minmaxElement comparison

RandomAccess

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
@wilzbach
wilzbach / filter.d
Last active June 20, 2017 01:15
For all Dscanner checks find all failing module
#!/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;
@wilzbach
wilzbach / mangling.ipynb
Last active July 15, 2017 21:43
Comparison of symbol length between pr/5866 and master
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wilzbach
wilzbach / Makefile
Created December 2, 2017 11:27
Makefile with D compiler bootstrapping
DMD=bin/dmd2/linux/bin64/dmd
DMD_VERSION=2.074.0
LDC=bin/ldc2-$(LDC_VERSION)-linux-$(PLATFORM)/bin/ldc2
LDC_VERSION=1.2.0
DFLAGS=-g
PLATFORM=x86_64
################################################################################
# Auto-bootstrap DMD & LDC for outdated Debian/Ubuntu
################################################################################
@wilzbach
wilzbach / output.md
Last active February 11, 2019 13:28
Measure import time for each module in Phobos
module bare import time
std.regex 1.04s
std.net.curl 0.29s
std.zip 0.19s
std.path 0.15s
std.socket 0.15s
std.file 0.14s
std.mmfile 0.14s
std.datetime 0.14s