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.085 ns (0 allocations: 0 bytes)
@btime $x.x500; ## Slower
11.121 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`
105.709 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();
3.819 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.205 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.737 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();
29.051 ms (1949728 allocations: 37.40 MiB)
29.817 ms (1950028 allocations: 45.03 MiB)
1.145 ms (728 allocations: 7.66 MiB)
1.596 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
2.527 ms (212 allocations: 38.16 MiB)
1.174 μs (29 allocations: 1.50 KiB)
440.874 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.890 ms (8 allocations: 7.63 MiB)
categorical:
15.323 ms (1000004 allocations: 30.52 MiB)
String
raw:
21.787 ms (4 allocations: 448 bytes)
categorical:
32.270 ms (1000004 allocations: 30.52 MiB)
Union{Missing, Int64}
raw:
6.025 ms (4 allocations: 464 bytes)
categorical:
15.817 ms (1000004 allocations: 30.52 MiB)
Union{Missing, String}
raw:
21.463 ms (4 allocations: 448 bytes)
categorical:
32.639 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 |
⋮ | ⋮ | ⋮ |
2499880 | d | 1 |
2499881 | d | 1 |
2499882 | d | 1 |
2499883 | d | 1 |
2499884 | d | 1 |
2499885 | d | 1 |
2499886 | d | 1 |
2499887 | d | 1 |
2499888 | d | 1 |
2499889 | d | 1 |
2499890 | d | 1 |
2499891 | d | 1 |
⋮
Row | x | y |
---|---|---|
Char | Int64 | |
1 | b | 1 |
2 | b | 1 |
3 | b | 1 |
4 | b | 1 |
5 | b | 1 |
6 | b | 1 |
7 | b | 1 |
8 | b | 1 |
9 | b | 1 |
10 | b | 1 |
11 | b | 1 |
12 | b | 1 |
13 | b | 1 |
⋮ | ⋮ | ⋮ |
2501409 | b | 1 |
2501410 | b | 1 |
2501411 | b | 1 |
2501412 | b | 1 |
2501413 | b | 1 |
2501414 | b | 1 |
2501415 | b | 1 |
2501416 | b | 1 |
2501417 | b | 1 |
2501418 | b | 1 |
2501419 | b | 1 |
2501420 | b | 1 |
traditional syntax, slow
@btime combine(v -> sum(v.y), $gdf)
16.437 ms (332 allocations: 19.09 MiB)
Row | x | x1 |
---|---|---|
Char | Int64 | |
1 | d | 2499891 |
2 | c | 2499309 |
3 | a | 2499380 |
4 | b | 2501420 |
use column selector
@btime combine($gdf, :y => sum)
6.901 ms (198 allocations: 10.14 KiB)
Row | x | y_sum |
---|---|---|
Char | Int64 | |
1 | d | 2499891 |
2 | c | 2499309 |
3 | a | 2499380 |
4 | b | 2501420 |
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 |
⋮ | ⋮ | ⋮ |
2499369 | a | 1 |
2499370 | a | 1 |
2499371 | a | 1 |
2499372 | a | 1 |
2499373 | a | 1 |
2499374 | a | 1 |
2499375 | a | 1 |
2499376 | a | 1 |
2499377 | a | 1 |
2499378 | a | 1 |
2499379 | a | 1 |
2499380 | 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 |
⋮ | ⋮ | ⋮ |
2499880 | d | 1 |
2499881 | d | 1 |
2499882 | d | 1 |
2499883 | d | 1 |
2499884 | d | 1 |
2499885 | d | 1 |
2499886 | d | 1 |
2499887 | d | 1 |
2499888 | d | 1 |
2499889 | d | 1 |
2499890 | d | 1 |
2499891 | d | 1 |
@btime combine($gdf, :y => sum)
6.843 ms (206 allocations: 10.62 KiB)
Row | x | y_sum |
---|---|---|
Cat… | Int64 | |
1 | a | 2499380 |
2 | b | 2501420 |
3 | c | 2499309 |
4 | d | 2499891 |
transform!(df, :x => PooledArray{Char} => :x)
Row | x | y |
---|---|---|
Char | Int64 | |
1 | d | 1 |
2 | c | 1 |
3 | c | 1 |
4 | a | 1 |
5 | c | 1 |
6 | a | 1 |
7 | c | 1 |
8 | c | 1 |
9 | d | 1 |
10 | c | 1 |
11 | d | 1 |
12 | d | 1 |
13 | d | 1 |
⋮ | ⋮ | ⋮ |
9999989 | c | 1 |
9999990 | c | 1 |
9999991 | b | 1 |
9999992 | a | 1 |
9999993 | d | 1 |
9999994 | a | 1 |
9999995 | d | 1 |
9999996 | c | 1 |
9999997 | c | 1 |
9999998 | d | 1 |
9999999 | a | 1 |
10000000 | d | 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 |
⋮ | ⋮ | ⋮ |
2499880 | d | 1 |
2499881 | d | 1 |
2499882 | d | 1 |
2499883 | d | 1 |
2499884 | d | 1 |
2499885 | d | 1 |
2499886 | d | 1 |
2499887 | d | 1 |
2499888 | d | 1 |
2499889 | d | 1 |
2499890 | d | 1 |
2499891 | d | 1 |
⋮
Row | x | y |
---|---|---|
Char | Int64 | |
1 | b | 1 |
2 | b | 1 |
3 | b | 1 |
4 | b | 1 |
5 | b | 1 |
6 | b | 1 |
7 | b | 1 |
8 | b | 1 |
9 | b | 1 |
10 | b | 1 |
11 | b | 1 |
12 | b | 1 |
13 | b | 1 |
⋮ | ⋮ | ⋮ |
2501409 | b | 1 |
2501410 | b | 1 |
2501411 | b | 1 |
2501412 | b | 1 |
2501413 | b | 1 |
2501414 | b | 1 |
2501415 | b | 1 |
2501416 | b | 1 |
2501417 | b | 1 |
2501418 | b | 1 |
2501419 | b | 1 |
2501420 | b | 1 |
@btime combine($gdf, :y => sum)
6.905 ms (200 allocations: 10.20 KiB)
Row | x | y_sum |
---|---|---|
Char | Int64 | |
1 | d | 2499891 |
2 | c | 2499309 |
3 | a | 2499380 |
4 | b | 2501420 |
Use views instead of materializing a new DataFrame#
x = DataFrame(rand(100, 1000), :auto)
@btime $x[1:1, :]
178.674 μs (3993 allocations: 159.07 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.569179 | 0.339293 | 0.805134 | 0.816853 | 0.871954 | 0.284804 | 0.182257 | 0.918169 | 0.268791 | 0.452361 | 0.537572 | 0.177828 | 0.938777 | 0.268184 | 0.18688 | 0.791902 | 0.0107445 | 0.747737 | 0.432973 | 0.26199 | 0.0510824 | 0.938631 | 0.36447 | 0.331288 | 0.063129 | 0.142311 | 0.747728 | 0.34442 | 0.508099 | 0.781617 | 0.708317 | 0.323466 | 0.226984 | 0.679254 | 0.707307 | 0.912694 | 0.242155 | 0.487742 | 0.549296 | 0.881762 | 0.735189 | 0.503539 | 0.587135 | 0.45486 | 0.985653 | 0.289627 | 0.79386 | 0.408735 | 0.162235 | 0.221384 | 0.658306 | 0.490437 | 0.48231 | 0.521142 | 0.832529 | 0.717641 | 0.812372 | 0.0513109 | 0.278066 | 0.471986 | 0.147352 | 0.133897 | 0.00310868 | 0.375954 | 0.267621 | 0.143985 | 0.491989 | 0.236704 | 0.731115 | 0.7315 | 0.646703 | 0.889679 | 0.775376 | 0.888251 | 0.147639 | 0.845112 | 0.365046 | 0.493102 | 0.362595 | 0.0714852 | 0.00129075 | 0.488794 | 0.976273 | 0.735828 | 0.501655 | 0.409407 | 0.751253 | 0.487938 | 0.592283 | 0.760621 | 0.342584 | 0.311355 | 0.145755 | 0.612937 | 0.0476068 | 0.375446 | 0.317837 | 0.366398 | 0.944431 | 0.605746 | ⋯ |
@btime $x[1, :]
22.230 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.569179 | 0.339293 | 0.805134 | 0.816853 | 0.871954 | 0.284804 | 0.182257 | 0.918169 | 0.268791 | 0.452361 | 0.537572 | 0.177828 | 0.938777 | 0.268184 | 0.18688 | 0.791902 | 0.0107445 | 0.747737 | 0.432973 | 0.26199 | 0.0510824 | 0.938631 | 0.36447 | 0.331288 | 0.063129 | 0.142311 | 0.747728 | 0.34442 | 0.508099 | 0.781617 | 0.708317 | 0.323466 | 0.226984 | 0.679254 | 0.707307 | 0.912694 | 0.242155 | 0.487742 | 0.549296 | 0.881762 | 0.735189 | 0.503539 | 0.587135 | 0.45486 | 0.985653 | 0.289627 | 0.79386 | 0.408735 | 0.162235 | 0.221384 | 0.658306 | 0.490437 | 0.48231 | 0.521142 | 0.832529 | 0.717641 | 0.812372 | 0.0513109 | 0.278066 | 0.471986 | 0.147352 | 0.133897 | 0.00310868 | 0.375954 | 0.267621 | 0.143985 | 0.491989 | 0.236704 | 0.731115 | 0.7315 | 0.646703 | 0.889679 | 0.775376 | 0.888251 | 0.147639 | 0.845112 | 0.365046 | 0.493102 | 0.362595 | 0.0714852 | 0.00129075 | 0.488794 | 0.976273 | 0.735828 | 0.501655 | 0.409407 | 0.751253 | 0.487938 | 0.592283 | 0.760621 | 0.342584 | 0.311355 | 0.145755 | 0.612937 | 0.0476068 | 0.375446 | 0.317837 | 0.366398 | 0.944431 | 0.605746 | ⋯ |
@btime view($x, 1:1, :)
22.230 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.569179 | 0.339293 | 0.805134 | 0.816853 | 0.871954 | 0.284804 | 0.182257 | 0.918169 | 0.268791 | 0.452361 | 0.537572 | 0.177828 | 0.938777 | 0.268184 | 0.18688 | 0.791902 | 0.0107445 | 0.747737 | 0.432973 | 0.26199 | 0.0510824 | 0.938631 | 0.36447 | 0.331288 | 0.063129 | 0.142311 | 0.747728 | 0.34442 | 0.508099 | 0.781617 | 0.708317 | 0.323466 | 0.226984 | 0.679254 | 0.707307 | 0.912694 | 0.242155 | 0.487742 | 0.549296 | 0.881762 | 0.735189 | 0.503539 | 0.587135 | 0.45486 | 0.985653 | 0.289627 | 0.79386 | 0.408735 | 0.162235 | 0.221384 | 0.658306 | 0.490437 | 0.48231 | 0.521142 | 0.832529 | 0.717641 | 0.812372 | 0.0513109 | 0.278066 | 0.471986 | 0.147352 | 0.133897 | 0.00310868 | 0.375954 | 0.267621 | 0.143985 | 0.491989 | 0.236704 | 0.731115 | 0.7315 | 0.646703 | 0.889679 | 0.775376 | 0.888251 | 0.147639 | 0.845112 | 0.365046 | 0.493102 | 0.362595 | 0.0714852 | 0.00129075 | 0.488794 | 0.976273 | 0.735828 | 0.501655 | 0.409407 | 0.751253 | 0.487938 | 0.592283 | 0.760621 | 0.342584 | 0.311355 | 0.145755 | 0.612937 | 0.0476068 | 0.375446 | 0.317837 | 0.366398 | 0.944431 | 0.605746 | ⋯ |
@btime $x[1:1, 1:20]
3.810 μ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.569179 | 0.339293 | 0.805134 | 0.816853 | 0.871954 | 0.284804 | 0.182257 | 0.918169 | 0.268791 | 0.452361 | 0.537572 | 0.177828 | 0.938777 | 0.268184 | 0.18688 | 0.791902 | 0.0107445 | 0.747737 | 0.432973 | 0.26199 |
@btime $x[1, 1:20]
21.909 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.569179 | 0.339293 | 0.805134 | 0.816853 | 0.871954 | 0.284804 | 0.182257 | 0.918169 | 0.268791 | 0.452361 | 0.537572 | 0.177828 | 0.938777 | 0.268184 | 0.18688 | 0.791902 | 0.0107445 | 0.747737 | 0.432973 | 0.26199 |
@btime view($x, 1:1, 1:20)
22.532 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.569179 | 0.339293 | 0.805134 | 0.816853 | 0.871954 | 0.284804 | 0.182257 | 0.918169 | 0.268791 | 0.452361 | 0.537572 | 0.177828 | 0.938777 | 0.268184 | 0.18688 | 0.791902 | 0.0107445 | 0.747737 | 0.432973 | 0.26199 |
This notebook was generated using Literate.jl.