Performance tips#
using DataFrames
using BenchmarkTools
using CategoricalArrays
using PooledArrays
using Random
Access by column number is faster than by name#
x = DataFrame(rand(5, 1000), :auto)
@btime $x[!, 500]; ## Faster
3.857 ns (0 allocations: 0 bytes)
@btime $x.x500; ## Slower
14.953 ns (0 allocations: 0 bytes)
When working with data DataFrame use barrier functions or type annotation#
function f_bad() ## this function will be slow
Random.seed!(1)
x = DataFrame(rand(1000000, 2), :auto)
y, z = x[!, 1], x[!, 2]
p = 0.0
for i in 1:nrow(x)
p += y[i] * z[i]
end
p
end
@btime f_bad();
# if you run @code_warntype f_bad() then you notice
# that Julia does not know column types of `DataFrame`
189.746 ms (5999022 allocations: 122.06 MiB)
solution 1 is to use barrier function (it should be possible to use it in almost any code) for the calculation. You will notice much less memopry allocations and faster performance.
function f_inner(y, z)
p = 0.0
for i in eachindex(y, z)
p += y[i] * z[i]
end
p
end
function f_barrier()
Random.seed!(1)
x = DataFrame(rand(1000000, 2), :auto)
f_inner(x[!, 1], x[!, 2])
end
@btime f_barrier();
4.215 ms (44 allocations: 30.52 MiB)
or use inbuilt function if possible
using LinearAlgebra
function f_inbuilt()
Random.seed!(1)
x = DataFrame(rand(1000000, 2), :auto)
dot(x[!, 1], x[!, 2])
end
@btime f_inbuilt();
3.770 ms (44 allocations: 30.52 MiB)
solution 2 is to provide the types of extracted columns. However, there are cases in which you will not know these types.
function f_typed()
Random.seed!(1)
x = DataFrame(rand(1000000, 2), :auto)
y::Vector{Float64}, z::Vector{Float64} = x[!, 1], x[!, 2]
p = 0.0
for i in 1:nrow(x)
p += y[i] * z[i]
end
p
end
@btime f_typed();
3.871 ms (44 allocations: 30.52 MiB)
In general for tall and narrow tables it is often useful to use Tables.rowtable
, Tables.columntable
or Tables.namedtupleiterator
for intermediate processing of data in a type-stable way.
Consider using delayed DataFrame
creation technique#
also notice the difference in performance between copying vs non-copying data frame creation
function f1()
x = DataFrame([Vector{Float64}(undef, 10^4) for i in 1:100], :auto, copycols=false) ## we work with a DataFrame directly
for c in 1:ncol(x)
d = x[!, c]
for r in 1:nrow(x)
d[r] = rand()
end
end
x
end
function f1a()
x = DataFrame([Vector{Float64}(undef, 10^4) for i in 1:100], :auto) ## we work with a DataFrame directly
for c in 1:ncol(x)
d = x[!, c]
for r in 1:nrow(x)
d[r] = rand()
end
end
x
end
function f2()
x = Vector{Any}(undef, 100)
for c in 1:length(x)
d = Vector{Float64}(undef, 10^4)
for r in eachindex(d)
d[r] = rand()
end
x[c] = d
end
DataFrame(x, :auto, copycols=false) ## we delay creation of DataFrame after we have our job done
end
function f2a()
x = Vector{Any}(undef, 100)
for c in eachindex(x)
d = Vector{Float64}(undef, 10^4)
for r in eachindex(d)
d[r] = rand()
end
x[c] = d
end
DataFrame(x, :auto) ## we delay creation of DataFrame after we have our job done
end
@btime f1();
@btime f1a();
@btime f2();
@btime f2a();
27.945 ms (1949728 allocations: 37.40 MiB)
28.612 ms (1950028 allocations: 45.03 MiB)
1.146 ms (728 allocations: 7.66 MiB)
1.553 ms (1028 allocations: 15.29 MiB)
You can add rows to a DataFrame in place and it is fast#
x = DataFrame(rand(10^6, 5), :auto)
y = DataFrame(transpose(1.0:5.0), :auto)
z = [1.0:5.0;]
@btime vcat($x, $y); ## creates a new DataFrame - slow
@btime append!($x, $y); ## in place - fast
x = DataFrame(rand(10^6, 5), :auto) ## reset to the same starting point
@btime push!($x, $z); ## add a single row in place - fast
1.860 ms (212 allocations: 38.16 MiB)
1.182 μs (29 allocations: 1.50 KiB)
427.578 ns (16 allocations: 256 bytes)
Allowing missing as well as categorical slows down computations#
using StatsBase
function test(data) ## uses countmap function to test performance
println(eltype(data))
x = rand(data, 10^6)
y = categorical(x)
println(" raw:")
@btime countmap($x)
println(" categorical:")
@btime countmap($y)
nothing
end
test(1:10)
test([randstring() for i in 1:10])
test(allowmissing(1:10))
test(allowmissing([randstring() for i in 1:10]))
Int64
raw:
1.946 ms (8 allocations: 7.63 MiB)
categorical:
15.488 ms (1000004 allocations: 30.52 MiB)
String
raw:
21.136 ms (4 allocations: 448 bytes)
categorical:
31.496 ms (1000004 allocations: 30.52 MiB)
Union{Missing, Int64}
raw:
5.968 ms (4 allocations: 464 bytes)
categorical:
15.863 ms (1000004 allocations: 30.52 MiB)
Union{Missing, String}
raw:
19.541 ms (4 allocations: 448 bytes)
categorical:
29.501 ms (1000004 allocations: 30.52 MiB)
When aggregating use column selector and prefer integer, categorical, or pooled array grouping variable#
df = DataFrame(x=rand('a':'d', 10^7), y=1);
gdf = groupby(df, :x)
GroupedDataFrame with 4 groups based on key: x
Row | x | y |
---|---|---|
Char | Int64 | |
1 | d | 1 |
2 | d | 1 |
3 | d | 1 |
4 | d | 1 |
5 | d | 1 |
6 | d | 1 |
7 | d | 1 |
8 | d | 1 |
9 | d | 1 |
10 | d | 1 |
11 | d | 1 |
12 | d | 1 |
13 | d | 1 |
⋮ | ⋮ | ⋮ |
2501716 | d | 1 |
2501717 | d | 1 |
2501718 | d | 1 |
2501719 | d | 1 |
2501720 | d | 1 |
2501721 | d | 1 |
2501722 | d | 1 |
2501723 | d | 1 |
2501724 | d | 1 |
2501725 | d | 1 |
2501726 | d | 1 |
2501727 | d | 1 |
⋮
Row | x | y |
---|---|---|
Char | Int64 | |
1 | c | 1 |
2 | c | 1 |
3 | c | 1 |
4 | c | 1 |
5 | c | 1 |
6 | c | 1 |
7 | c | 1 |
8 | c | 1 |
9 | c | 1 |
10 | c | 1 |
11 | c | 1 |
12 | c | 1 |
13 | c | 1 |
⋮ | ⋮ | ⋮ |
2498287 | c | 1 |
2498288 | c | 1 |
2498289 | c | 1 |
2498290 | c | 1 |
2498291 | c | 1 |
2498292 | c | 1 |
2498293 | c | 1 |
2498294 | c | 1 |
2498295 | c | 1 |
2498296 | c | 1 |
2498297 | c | 1 |
2498298 | c | 1 |
traditional syntax, slow
@btime combine(v -> sum(v.y), $gdf)
16.411 ms (332 allocations: 19.10 MiB)
Row | x | x1 |
---|---|---|
Char | Int64 | |
1 | d | 2501727 |
2 | a | 2500441 |
3 | b | 2499534 |
4 | c | 2498298 |
use column selector
@btime combine($gdf, :y => sum)
6.973 ms (198 allocations: 10.14 KiB)
Row | x | y_sum |
---|---|---|
Char | Int64 | |
1 | d | 2501727 |
2 | a | 2500441 |
3 | b | 2499534 |
4 | c | 2498298 |
transform!(df, :x => categorical => :x);
gdf = groupby(df, :x)
GroupedDataFrame with 4 groups based on key: x
Row | x | y |
---|---|---|
Cat… | Int64 | |
1 | a | 1 |
2 | a | 1 |
3 | a | 1 |
4 | a | 1 |
5 | a | 1 |
6 | a | 1 |
7 | a | 1 |
8 | a | 1 |
9 | a | 1 |
10 | a | 1 |
11 | a | 1 |
12 | a | 1 |
13 | a | 1 |
⋮ | ⋮ | ⋮ |
2500430 | a | 1 |
2500431 | a | 1 |
2500432 | a | 1 |
2500433 | a | 1 |
2500434 | a | 1 |
2500435 | a | 1 |
2500436 | a | 1 |
2500437 | a | 1 |
2500438 | a | 1 |
2500439 | a | 1 |
2500440 | a | 1 |
2500441 | a | 1 |
⋮
Row | x | y |
---|---|---|
Cat… | Int64 | |
1 | d | 1 |
2 | d | 1 |
3 | d | 1 |
4 | d | 1 |
5 | d | 1 |
6 | d | 1 |
7 | d | 1 |
8 | d | 1 |
9 | d | 1 |
10 | d | 1 |
11 | d | 1 |
12 | d | 1 |
13 | d | 1 |
⋮ | ⋮ | ⋮ |
2501716 | d | 1 |
2501717 | d | 1 |
2501718 | d | 1 |
2501719 | d | 1 |
2501720 | d | 1 |
2501721 | d | 1 |
2501722 | d | 1 |
2501723 | d | 1 |
2501724 | d | 1 |
2501725 | d | 1 |
2501726 | d | 1 |
2501727 | d | 1 |
@btime combine($gdf, :y => sum)
6.860 ms (206 allocations: 10.62 KiB)
Row | x | y_sum |
---|---|---|
Cat… | Int64 | |
1 | a | 2500441 |
2 | b | 2499534 |
3 | c | 2498298 |
4 | d | 2501727 |
transform!(df, :x => PooledArray{Char} => :x)
Row | x | y |
---|---|---|
Char | Int64 | |
1 | d | 1 |
2 | a | 1 |
3 | b | 1 |
4 | d | 1 |
5 | b | 1 |
6 | b | 1 |
7 | c | 1 |
8 | c | 1 |
9 | b | 1 |
10 | b | 1 |
11 | a | 1 |
12 | b | 1 |
13 | b | 1 |
⋮ | ⋮ | ⋮ |
9999989 | c | 1 |
9999990 | b | 1 |
9999991 | b | 1 |
9999992 | c | 1 |
9999993 | d | 1 |
9999994 | c | 1 |
9999995 | c | 1 |
9999996 | d | 1 |
9999997 | a | 1 |
9999998 | b | 1 |
9999999 | c | 1 |
10000000 | b | 1 |
gdf = groupby(df, :x)
GroupedDataFrame with 4 groups based on key: x
Row | x | y |
---|---|---|
Char | Int64 | |
1 | d | 1 |
2 | d | 1 |
3 | d | 1 |
4 | d | 1 |
5 | d | 1 |
6 | d | 1 |
7 | d | 1 |
8 | d | 1 |
9 | d | 1 |
10 | d | 1 |
11 | d | 1 |
12 | d | 1 |
13 | d | 1 |
⋮ | ⋮ | ⋮ |
2501716 | d | 1 |
2501717 | d | 1 |
2501718 | d | 1 |
2501719 | d | 1 |
2501720 | d | 1 |
2501721 | d | 1 |
2501722 | d | 1 |
2501723 | d | 1 |
2501724 | d | 1 |
2501725 | d | 1 |
2501726 | d | 1 |
2501727 | d | 1 |
⋮
Row | x | y |
---|---|---|
Char | Int64 | |
1 | c | 1 |
2 | c | 1 |
3 | c | 1 |
4 | c | 1 |
5 | c | 1 |
6 | c | 1 |
7 | c | 1 |
8 | c | 1 |
9 | c | 1 |
10 | c | 1 |
11 | c | 1 |
12 | c | 1 |
13 | c | 1 |
⋮ | ⋮ | ⋮ |
2498287 | c | 1 |
2498288 | c | 1 |
2498289 | c | 1 |
2498290 | c | 1 |
2498291 | c | 1 |
2498292 | c | 1 |
2498293 | c | 1 |
2498294 | c | 1 |
2498295 | c | 1 |
2498296 | c | 1 |
2498297 | c | 1 |
2498298 | c | 1 |
@btime combine($gdf, :y => sum)
6.923 ms (200 allocations: 10.20 KiB)
Row | x | y_sum |
---|---|---|
Char | Int64 | |
1 | d | 2501727 |
2 | a | 2500441 |
3 | b | 2499534 |
4 | c | 2498298 |
Use views instead of materializing a new DataFrame#
x = DataFrame(rand(100, 1000), :auto)
@btime $x[1:1, :]
180.477 μs (3993 allocations: 159.03 KiB)
Row | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | x10 | x11 | x12 | x13 | x14 | x15 | x16 | x17 | x18 | x19 | x20 | x21 | x22 | x23 | x24 | x25 | x26 | x27 | x28 | x29 | x30 | x31 | x32 | x33 | x34 | x35 | x36 | x37 | x38 | x39 | x40 | x41 | x42 | x43 | x44 | x45 | x46 | x47 | x48 | x49 | x50 | x51 | x52 | x53 | x54 | x55 | x56 | x57 | x58 | x59 | x60 | x61 | x62 | x63 | x64 | x65 | x66 | x67 | x68 | x69 | x70 | x71 | x72 | x73 | x74 | x75 | x76 | x77 | x78 | x79 | x80 | x81 | x82 | x83 | x84 | x85 | x86 | x87 | x88 | x89 | x90 | x91 | x92 | x93 | x94 | x95 | x96 | x97 | x98 | x99 | x100 | ⋯ |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | ⋯ | |
1 | 0.565853 | 0.905904 | 0.981852 | 0.963662 | 0.829862 | 0.126634 | 0.934865 | 0.353803 | 0.645645 | 0.0817537 | 0.899598 | 0.281844 | 0.656293 | 0.756012 | 0.232053 | 0.458563 | 0.772053 | 0.0639178 | 0.782881 | 0.544549 | 0.637041 | 0.131068 | 0.56172 | 0.572485 | 0.612004 | 0.496685 | 0.988737 | 0.414718 | 0.761914 | 0.5208 | 0.377727 | 0.38172 | 0.218342 | 0.206418 | 0.369863 | 0.587736 | 0.548522 | 0.92162 | 0.936342 | 0.864187 | 0.677156 | 0.419425 | 0.479356 | 0.0582411 | 0.853625 | 0.883459 | 0.527113 | 0.624496 | 0.805167 | 0.607369 | 0.650872 | 0.89497 | 0.897811 | 0.70586 | 0.833061 | 0.623962 | 0.869884 | 0.746071 | 0.0290109 | 0.117292 | 0.0885775 | 0.525337 | 0.150797 | 0.310911 | 0.641844 | 0.612215 | 0.836106 | 0.403074 | 0.200835 | 0.274667 | 0.768654 | 0.00717039 | 0.026151 | 0.940375 | 0.712015 | 0.434711 | 0.938142 | 0.497345 | 0.0356626 | 0.750823 | 0.496258 | 0.651254 | 0.84246 | 0.0421448 | 0.118632 | 0.487333 | 0.540846 | 0.495325 | 0.112902 | 0.647389 | 0.402041 | 0.83743 | 0.628873 | 0.0407883 | 0.8497 | 0.0373333 | 0.187617 | 0.417632 | 0.480828 | 0.864196 | ⋯ |
@btime $x[1, :]
23.457 ns (0 allocations: 0 bytes)
Row | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | x10 | x11 | x12 | x13 | x14 | x15 | x16 | x17 | x18 | x19 | x20 | x21 | x22 | x23 | x24 | x25 | x26 | x27 | x28 | x29 | x30 | x31 | x32 | x33 | x34 | x35 | x36 | x37 | x38 | x39 | x40 | x41 | x42 | x43 | x44 | x45 | x46 | x47 | x48 | x49 | x50 | x51 | x52 | x53 | x54 | x55 | x56 | x57 | x58 | x59 | x60 | x61 | x62 | x63 | x64 | x65 | x66 | x67 | x68 | x69 | x70 | x71 | x72 | x73 | x74 | x75 | x76 | x77 | x78 | x79 | x80 | x81 | x82 | x83 | x84 | x85 | x86 | x87 | x88 | x89 | x90 | x91 | x92 | x93 | x94 | x95 | x96 | x97 | x98 | x99 | x100 | ⋯ |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | ⋯ | |
1 | 0.565853 | 0.905904 | 0.981852 | 0.963662 | 0.829862 | 0.126634 | 0.934865 | 0.353803 | 0.645645 | 0.0817537 | 0.899598 | 0.281844 | 0.656293 | 0.756012 | 0.232053 | 0.458563 | 0.772053 | 0.0639178 | 0.782881 | 0.544549 | 0.637041 | 0.131068 | 0.56172 | 0.572485 | 0.612004 | 0.496685 | 0.988737 | 0.414718 | 0.761914 | 0.5208 | 0.377727 | 0.38172 | 0.218342 | 0.206418 | 0.369863 | 0.587736 | 0.548522 | 0.92162 | 0.936342 | 0.864187 | 0.677156 | 0.419425 | 0.479356 | 0.0582411 | 0.853625 | 0.883459 | 0.527113 | 0.624496 | 0.805167 | 0.607369 | 0.650872 | 0.89497 | 0.897811 | 0.70586 | 0.833061 | 0.623962 | 0.869884 | 0.746071 | 0.0290109 | 0.117292 | 0.0885775 | 0.525337 | 0.150797 | 0.310911 | 0.641844 | 0.612215 | 0.836106 | 0.403074 | 0.200835 | 0.274667 | 0.768654 | 0.00717039 | 0.026151 | 0.940375 | 0.712015 | 0.434711 | 0.938142 | 0.497345 | 0.0356626 | 0.750823 | 0.496258 | 0.651254 | 0.84246 | 0.0421448 | 0.118632 | 0.487333 | 0.540846 | 0.495325 | 0.112902 | 0.647389 | 0.402041 | 0.83743 | 0.628873 | 0.0407883 | 0.8497 | 0.0373333 | 0.187617 | 0.417632 | 0.480828 | 0.864196 | ⋯ |
@btime view($x, 1:1, :)
23.457 ns (0 allocations: 0 bytes)
Row | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | x10 | x11 | x12 | x13 | x14 | x15 | x16 | x17 | x18 | x19 | x20 | x21 | x22 | x23 | x24 | x25 | x26 | x27 | x28 | x29 | x30 | x31 | x32 | x33 | x34 | x35 | x36 | x37 | x38 | x39 | x40 | x41 | x42 | x43 | x44 | x45 | x46 | x47 | x48 | x49 | x50 | x51 | x52 | x53 | x54 | x55 | x56 | x57 | x58 | x59 | x60 | x61 | x62 | x63 | x64 | x65 | x66 | x67 | x68 | x69 | x70 | x71 | x72 | x73 | x74 | x75 | x76 | x77 | x78 | x79 | x80 | x81 | x82 | x83 | x84 | x85 | x86 | x87 | x88 | x89 | x90 | x91 | x92 | x93 | x94 | x95 | x96 | x97 | x98 | x99 | x100 | ⋯ |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | ⋯ | |
1 | 0.565853 | 0.905904 | 0.981852 | 0.963662 | 0.829862 | 0.126634 | 0.934865 | 0.353803 | 0.645645 | 0.0817537 | 0.899598 | 0.281844 | 0.656293 | 0.756012 | 0.232053 | 0.458563 | 0.772053 | 0.0639178 | 0.782881 | 0.544549 | 0.637041 | 0.131068 | 0.56172 | 0.572485 | 0.612004 | 0.496685 | 0.988737 | 0.414718 | 0.761914 | 0.5208 | 0.377727 | 0.38172 | 0.218342 | 0.206418 | 0.369863 | 0.587736 | 0.548522 | 0.92162 | 0.936342 | 0.864187 | 0.677156 | 0.419425 | 0.479356 | 0.0582411 | 0.853625 | 0.883459 | 0.527113 | 0.624496 | 0.805167 | 0.607369 | 0.650872 | 0.89497 | 0.897811 | 0.70586 | 0.833061 | 0.623962 | 0.869884 | 0.746071 | 0.0290109 | 0.117292 | 0.0885775 | 0.525337 | 0.150797 | 0.310911 | 0.641844 | 0.612215 | 0.836106 | 0.403074 | 0.200835 | 0.274667 | 0.768654 | 0.00717039 | 0.026151 | 0.940375 | 0.712015 | 0.434711 | 0.938142 | 0.497345 | 0.0356626 | 0.750823 | 0.496258 | 0.651254 | 0.84246 | 0.0421448 | 0.118632 | 0.487333 | 0.540846 | 0.495325 | 0.112902 | 0.647389 | 0.402041 | 0.83743 | 0.628873 | 0.0407883 | 0.8497 | 0.0373333 | 0.187617 | 0.417632 | 0.480828 | 0.864196 | ⋯ |
@btime $x[1:1, 1:20]
3.924 μs (70 allocations: 3.09 KiB)
Row | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | x10 | x11 | x12 | x13 | x14 | x15 | x16 | x17 | x18 | x19 | x20 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | |
1 | 0.565853 | 0.905904 | 0.981852 | 0.963662 | 0.829862 | 0.126634 | 0.934865 | 0.353803 | 0.645645 | 0.0817537 | 0.899598 | 0.281844 | 0.656293 | 0.756012 | 0.232053 | 0.458563 | 0.772053 | 0.0639178 | 0.782881 | 0.544549 |
@btime $x[1, 1:20]
24.383 ns (0 allocations: 0 bytes)
Row | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | x10 | x11 | x12 | x13 | x14 | x15 | x16 | x17 | x18 | x19 | x20 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | |
1 | 0.565853 | 0.905904 | 0.981852 | 0.963662 | 0.829862 | 0.126634 | 0.934865 | 0.353803 | 0.645645 | 0.0817537 | 0.899598 | 0.281844 | 0.656293 | 0.756012 | 0.232053 | 0.458563 | 0.772053 | 0.0639178 | 0.782881 | 0.544549 |
@btime view($x, 1:1, 1:20)
24.383 ns (0 allocations: 0 bytes)
Row | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | x10 | x11 | x12 | x13 | x14 | x15 | x16 | x17 | x18 | x19 | x20 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | |
1 | 0.565853 | 0.905904 | 0.981852 | 0.963662 | 0.829862 | 0.126634 | 0.934865 | 0.353803 | 0.645645 | 0.0817537 | 0.899598 | 0.281844 | 0.656293 | 0.756012 | 0.232053 | 0.458563 | 0.772053 | 0.0639178 | 0.782881 | 0.544549 |
This notebook was generated using Literate.jl.