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.095 ns (0 allocations: 0 bytes)
@btime $x.x500; ## Slower
11.122 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`
99.692 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.277 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.661 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.887 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();
28.362 ms (1949728 allocations: 37.40 MiB)
28.251 ms (1950028 allocations: 45.03 MiB)
1.156 ms (728 allocations: 7.66 MiB)
1.607 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.894 ms (212 allocations: 38.16 MiB)
1.132 μs (29 allocations: 1.50 KiB)
441.889 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.824 ms (8 allocations: 7.63 MiB)
categorical:
15.564 ms (1000004 allocations: 30.52 MiB)
String
raw:
20.521 ms (4 allocations: 448 bytes)
categorical:
31.713 ms (1000004 allocations: 30.52 MiB)
Union{Missing, Int64}
raw:
5.983 ms (4 allocations: 464 bytes)
categorical:
15.494 ms (1000004 allocations: 30.52 MiB)
Union{Missing, String}
raw:
19.281 ms (4 allocations: 448 bytes)
categorical:
29.505 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 | 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 |
⋮ | ⋮ | ⋮ |
2499881 | b | 1 |
2499882 | b | 1 |
2499883 | b | 1 |
2499884 | b | 1 |
2499885 | b | 1 |
2499886 | b | 1 |
2499887 | b | 1 |
2499888 | b | 1 |
2499889 | b | 1 |
2499890 | b | 1 |
2499891 | b | 1 |
2499892 | b | 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 |
⋮ | ⋮ | ⋮ |
2499131 | c | 1 |
2499132 | c | 1 |
2499133 | c | 1 |
2499134 | c | 1 |
2499135 | c | 1 |
2499136 | c | 1 |
2499137 | c | 1 |
2499138 | c | 1 |
2499139 | c | 1 |
2499140 | c | 1 |
2499141 | c | 1 |
2499142 | c | 1 |
traditional syntax, slow
@btime combine(v -> sum(v.y), $gdf)
17.054 ms (332 allocations: 19.09 MiB)
Row | x | x1 |
---|---|---|
Char | Int64 | |
1 | b | 2499892 |
2 | d | 2498228 |
3 | a | 2502738 |
4 | c | 2499142 |
use column selector
@btime combine($gdf, :y => sum)
6.853 ms (198 allocations: 10.14 KiB)
Row | x | y_sum |
---|---|---|
Char | Int64 | |
1 | b | 2499892 |
2 | d | 2498228 |
3 | a | 2502738 |
4 | c | 2499142 |
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 |
⋮ | ⋮ | ⋮ |
2502727 | a | 1 |
2502728 | a | 1 |
2502729 | a | 1 |
2502730 | a | 1 |
2502731 | a | 1 |
2502732 | a | 1 |
2502733 | a | 1 |
2502734 | a | 1 |
2502735 | a | 1 |
2502736 | a | 1 |
2502737 | a | 1 |
2502738 | 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 |
⋮ | ⋮ | ⋮ |
2498217 | d | 1 |
2498218 | d | 1 |
2498219 | d | 1 |
2498220 | d | 1 |
2498221 | d | 1 |
2498222 | d | 1 |
2498223 | d | 1 |
2498224 | d | 1 |
2498225 | d | 1 |
2498226 | d | 1 |
2498227 | d | 1 |
2498228 | d | 1 |
@btime combine($gdf, :y => sum)
6.883 ms (206 allocations: 10.62 KiB)
Row | x | y_sum |
---|---|---|
Cat… | Int64 | |
1 | a | 2502738 |
2 | b | 2499892 |
3 | c | 2499142 |
4 | d | 2498228 |
transform!(df, :x => PooledArray{Char} => :x)
Row | x | y |
---|---|---|
Char | Int64 | |
1 | b | 1 |
2 | d | 1 |
3 | a | 1 |
4 | d | 1 |
5 | b | 1 |
6 | c | 1 |
7 | b | 1 |
8 | d | 1 |
9 | d | 1 |
10 | c | 1 |
11 | d | 1 |
12 | a | 1 |
13 | d | 1 |
⋮ | ⋮ | ⋮ |
9999989 | b | 1 |
9999990 | b | 1 |
9999991 | c | 1 |
9999992 | a | 1 |
9999993 | a | 1 |
9999994 | a | 1 |
9999995 | c | 1 |
9999996 | c | 1 |
9999997 | d | 1 |
9999998 | c | 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 | 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 |
⋮ | ⋮ | ⋮ |
2499881 | b | 1 |
2499882 | b | 1 |
2499883 | b | 1 |
2499884 | b | 1 |
2499885 | b | 1 |
2499886 | b | 1 |
2499887 | b | 1 |
2499888 | b | 1 |
2499889 | b | 1 |
2499890 | b | 1 |
2499891 | b | 1 |
2499892 | b | 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 |
⋮ | ⋮ | ⋮ |
2499131 | c | 1 |
2499132 | c | 1 |
2499133 | c | 1 |
2499134 | c | 1 |
2499135 | c | 1 |
2499136 | c | 1 |
2499137 | c | 1 |
2499138 | c | 1 |
2499139 | c | 1 |
2499140 | c | 1 |
2499141 | c | 1 |
2499142 | c | 1 |
@btime combine($gdf, :y => sum)
6.877 ms (200 allocations: 10.20 KiB)
Row | x | y_sum |
---|---|---|
Char | Int64 | |
1 | b | 2499892 |
2 | d | 2498228 |
3 | a | 2502738 |
4 | c | 2499142 |
Use views instead of materializing a new DataFrame#
x = DataFrame(rand(100, 1000), :auto)
@btime $x[1:1, :]
178.073 μ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.134105 | 0.0119839 | 0.80118 | 0.29816 | 0.875661 | 0.0849515 | 0.319232 | 0.856822 | 0.272222 | 0.406149 | 0.793228 | 0.773672 | 0.202574 | 0.444473 | 0.359512 | 0.530218 | 0.00773591 | 0.896723 | 0.313556 | 0.737386 | 0.398533 | 0.39016 | 0.996516 | 0.233524 | 0.292958 | 0.349268 | 0.493418 | 0.0776396 | 0.603761 | 0.957692 | 0.336215 | 0.635226 | 0.203385 | 0.86762 | 0.207062 | 0.525631 | 0.604884 | 0.162609 | 0.266444 | 0.923934 | 0.0997255 | 0.744273 | 0.782608 | 0.400171 | 0.524721 | 0.362577 | 0.331129 | 0.619025 | 0.00112627 | 0.37121 | 0.329328 | 0.519182 | 0.762861 | 0.760448 | 0.82629 | 0.267479 | 0.918333 | 0.963585 | 0.910943 | 0.0644922 | 0.17805 | 0.187619 | 0.517915 | 0.112202 | 0.540578 | 0.526256 | 0.867859 | 0.753748 | 0.906489 | 0.828252 | 0.635565 | 0.357952 | 0.991087 | 0.421794 | 0.640939 | 0.581289 | 0.47546 | 0.986232 | 0.810611 | 0.863877 | 0.342379 | 0.314763 | 0.471149 | 0.907987 | 0.368039 | 0.0585712 | 0.847582 | 0.678445 | 0.978833 | 0.543357 | 0.651853 | 0.596623 | 0.273822 | 0.778689 | 0.524759 | 0.615975 | 0.222137 | 0.59717 | 0.217785 | 0.583383 | ⋯ |
@btime $x[1, :]
20.670 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.134105 | 0.0119839 | 0.80118 | 0.29816 | 0.875661 | 0.0849515 | 0.319232 | 0.856822 | 0.272222 | 0.406149 | 0.793228 | 0.773672 | 0.202574 | 0.444473 | 0.359512 | 0.530218 | 0.00773591 | 0.896723 | 0.313556 | 0.737386 | 0.398533 | 0.39016 | 0.996516 | 0.233524 | 0.292958 | 0.349268 | 0.493418 | 0.0776396 | 0.603761 | 0.957692 | 0.336215 | 0.635226 | 0.203385 | 0.86762 | 0.207062 | 0.525631 | 0.604884 | 0.162609 | 0.266444 | 0.923934 | 0.0997255 | 0.744273 | 0.782608 | 0.400171 | 0.524721 | 0.362577 | 0.331129 | 0.619025 | 0.00112627 | 0.37121 | 0.329328 | 0.519182 | 0.762861 | 0.760448 | 0.82629 | 0.267479 | 0.918333 | 0.963585 | 0.910943 | 0.0644922 | 0.17805 | 0.187619 | 0.517915 | 0.112202 | 0.540578 | 0.526256 | 0.867859 | 0.753748 | 0.906489 | 0.828252 | 0.635565 | 0.357952 | 0.991087 | 0.421794 | 0.640939 | 0.581289 | 0.47546 | 0.986232 | 0.810611 | 0.863877 | 0.342379 | 0.314763 | 0.471149 | 0.907987 | 0.368039 | 0.0585712 | 0.847582 | 0.678445 | 0.978833 | 0.543357 | 0.651853 | 0.596623 | 0.273822 | 0.778689 | 0.524759 | 0.615975 | 0.222137 | 0.59717 | 0.217785 | 0.583383 | ⋯ |
@btime view($x, 1:1, :)
19.745 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.134105 | 0.0119839 | 0.80118 | 0.29816 | 0.875661 | 0.0849515 | 0.319232 | 0.856822 | 0.272222 | 0.406149 | 0.793228 | 0.773672 | 0.202574 | 0.444473 | 0.359512 | 0.530218 | 0.00773591 | 0.896723 | 0.313556 | 0.737386 | 0.398533 | 0.39016 | 0.996516 | 0.233524 | 0.292958 | 0.349268 | 0.493418 | 0.0776396 | 0.603761 | 0.957692 | 0.336215 | 0.635226 | 0.203385 | 0.86762 | 0.207062 | 0.525631 | 0.604884 | 0.162609 | 0.266444 | 0.923934 | 0.0997255 | 0.744273 | 0.782608 | 0.400171 | 0.524721 | 0.362577 | 0.331129 | 0.619025 | 0.00112627 | 0.37121 | 0.329328 | 0.519182 | 0.762861 | 0.760448 | 0.82629 | 0.267479 | 0.918333 | 0.963585 | 0.910943 | 0.0644922 | 0.17805 | 0.187619 | 0.517915 | 0.112202 | 0.540578 | 0.526256 | 0.867859 | 0.753748 | 0.906489 | 0.828252 | 0.635565 | 0.357952 | 0.991087 | 0.421794 | 0.640939 | 0.581289 | 0.47546 | 0.986232 | 0.810611 | 0.863877 | 0.342379 | 0.314763 | 0.471149 | 0.907987 | 0.368039 | 0.0585712 | 0.847582 | 0.678445 | 0.978833 | 0.543357 | 0.651853 | 0.596623 | 0.273822 | 0.778689 | 0.524759 | 0.615975 | 0.222137 | 0.59717 | 0.217785 | 0.583383 | ⋯ |
@btime $x[1:1, 1:20]
3.753 μ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.134105 | 0.0119839 | 0.80118 | 0.29816 | 0.875661 | 0.0849515 | 0.319232 | 0.856822 | 0.272222 | 0.406149 | 0.793228 | 0.773672 | 0.202574 | 0.444473 | 0.359512 | 0.530218 | 0.00773591 | 0.896723 | 0.313556 | 0.737386 |
@btime $x[1, 1:20]
20.982 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.134105 | 0.0119839 | 0.80118 | 0.29816 | 0.875661 | 0.0849515 | 0.319232 | 0.856822 | 0.272222 | 0.406149 | 0.793228 | 0.773672 | 0.202574 | 0.444473 | 0.359512 | 0.530218 | 0.00773591 | 0.896723 | 0.313556 | 0.737386 |
@btime view($x, 1:1, 1:20)
21.283 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.134105 | 0.0119839 | 0.80118 | 0.29816 | 0.875661 | 0.0849515 | 0.319232 | 0.856822 | 0.272222 | 0.406149 | 0.793228 | 0.773672 | 0.202574 | 0.444473 | 0.359512 | 0.530218 | 0.00773591 | 0.896723 | 0.313556 | 0.737386 |
This notebook was generated using Literate.jl.