Skip to content

Instantly share code, notes, and snippets.

View Seelengrab's full-sized avatar

Sukera Seelengrab

View GitHub Profile
import Base.Threads
import Random
using Logging
function main(n=1000; exec=:base)
for seed in 1:n
executor = if exec == :base
BaseExecutor()
elseif exec == :par
ConcurrentExecutor(seed)
julia> @code_llvm length_separate_loop(Vector{Int}(undef, 1000))
; Function Signature: length_separate_loop(Array{Int64, 1})
; @ REPL[19]:1 within `length_separate_loop`
define void @julia_length_separate_loop_7603(ptr noundef nonnull align 8 dereferenceable(24) %"a::Array") #0 {
top:
%"new::Tuple" = alloca [1 x i64], align 8
%0 = getelementptr inbounds { ptr, ptr }, ptr %"a::Array", i64 0, i32 1
%1 = load ptr, ptr %0, align 8
%.unbox = load i64, ptr %1, align 8
%2 = getelementptr inbounds i8, ptr %"a::Array", i64 16
@Seelengrab
Seelengrab / MyPackage.jl
Created March 25, 2023 17:11
Module structure example
module MyPackage
include("utils.jl")
include("foobar.jl")
end
@Seelengrab
Seelengrab / Foo.jl
Last active April 2, 2022 12:17
Weird `extractvalue`s
using InteractiveUtils
struct Foo
a::UInt
b::NTuple{32, UInt8}
c::NTuple{4096, UInt8}
d::NTuple{4096, UInt8}
end
ident(_) = 0x0
@Seelengrab
Seelengrab / fast.jl
Last active November 18, 2023 22:26
gotta load fast
using BenchmarkTools
using StarWarsArrays
only_bench(x) = only(x)
one_idx_bench(x) = x[1]
deref_bench(x) = x[]
first_bench(x) = first(x)
twod_one_idx_bench(x) = x[1,1]
splat_bench(x) = x[ones(Int, 100)...]
end_bench(x) = x[end]