Skip to content

Instantly share code, notes, and snippets.

View 9il's full-sized avatar
☀️

Ilia Ki 9il

☀️
  • Bangkok
View GitHub Profile
/**
Vibe-based AWS client
*/
module vibe.aws.aws;
import std.algorithm;
import std.datetime;
import std.random;
import std.range;
/+
dub --compiler=../ldc2/bin/ldmd2 --build=release -- 100 101 1000000000 1 true
19 secs, 185 ms, 593 μs, and 6 hnsecs
17 secs, 641 ms, 669 μs, and 1 hnsec
2.0296e+13
2.0296e+13
+/
module benchmark_ndslice;
/+
dub --compiler=../ldc2/bin/ldmd2 --build=release -- 100 101 1000000000 1 true
[19 secs, 699 ms, and 409 μs, 19 secs, 309 ms, 528 μs, and 3 hnsecs]
[2.0296e+13, 2.0296e+13]
+/
module benchmark_ndslice;
import mir.ndslice;
@9il
9il / ndslice_asm.ldc.asm
Created December 25, 2015 07:57
NDSlice loops check
//LDC 0.17
//ldmd2 -c -O -inline -release -boundscheck=off -mcpu=native source/app.d -I../dip80-ndslice/source/
//otool -vt app.o > app.ldc.s
app.o:
(__TEXT,__text) sectionca
__D3app11nd_test_valFS3std12experimental7ndslice5slice17__T5SliceVmi3TPdZ5SlicedZv:
0000000000000000 pushq %r14
0000000000000002 pushq %rbx
0000000000000003 movq 0x18(%rsp), %r10
0000000000000008 testq %r10, %r10
@9il
9il / ndslice_asm.dmd.asm
Created December 25, 2015 07:52
NDSlice loops check
//dmd -c -O -inline -release -boundscheck=off source/app.d -I../dip80-ndslice/source/
//obj2asm app.o > app.dmd.s
Mach-O Object File
FLAT group
public _D3app11nd_test_valFS3std12experimental7ndslice5slice17__T5SliceVmi3TPdZ5SlicedZv
public _D3app14nd_test_slice1FS3std12experimental7ndslice5slice17__T5SliceVmi3TPdZ5SliceS3std12experimental7ndslice5slice17__T5SliceVmi1TPdZ5SliceZv
public _D3app14nd_test_slice2FS3std12experimental7ndslice5slice17__T5SliceVmi3TPdZ5SliceS3std12experimental7ndslice5slice17__T5SliceVmi2TPdZ5SliceZv
public _D3app14nd_test_slice3FS3std12experimental7ndslice5slice17__T5SliceVmi3TPdZ5SliceS3std12experimental7ndslice5slice17__T5SliceVmi3TPdZ5SliceZv
public _D3app14nd_test_array1FS3std12experimental7ndslice5slice17__T5SliceVmi3TPdZ5SliceAdZv
@9il
9il / ndslice_asm.d
Created December 25, 2015 07:50
NDSlice loops check
import std.experimental.ndslice;
//3D += number
void nd_test_val(Slice!(3, double*) slice, double value)
{
slice[] += value;
}
//3D += 1D
void nd_test_slice1(Slice!(3, double*) slice, Slice!(1, double*) value)
import std.datetime, std.stdio, std.uuid, std.traits;
void main()
{
import std.datetime, std.stdio, std.conv;
string str = "24c24a92-5fc8-11e5-9d70-feff819cdc9f";
ID id = ID("24c24a92-5fc8-11e5-9d70-feff819cdc9f");
UUID uuid = UUID("24c24a92-5fc8-11e5-9d70-feff819cdc9f");
size_t len;
auto b = benchmark!(
import std.stdio, std.datetime, std.uuid, std.conv;
struct NEW_UUID
{
union
{
ulong[2] ulongs;
static if(size_t.sizeof == 4)
uint[4] uints;
UUID id;
@9il
9il / matrix.d
Created September 12, 2013 18:08
struct Matrix(T)
{
this(size_t height, size_t width)
{
ptr = (new T[height * width]).ptr;
this.height = height;
this.width = width;
}
foreach(d; 0..dl)
{
auto pt = pdt[d];
auto nw = ndw[d];
auto qw = qdw[d];
foreach(w; 0..wl)
qwd[w, d] = qw[w] = nw[w] / dotProduct(pt, pwt[w]);
}
foreach(t; 0..tl)