Skip to content

Commit e03667d

Browse files
committed
working on lecture 5
1 parent 7b3ee33 commit e03667d

File tree

2 files changed

+426
-11
lines changed

2 files changed

+426
-11
lines changed

docs/src/lecture_02/lecture.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ nothing # hide
4444
# that `howl(sheep)` and `baa(wolf)` never happen.
4545
# For comparison, consider an alternative definition as follows
4646
#
47-
bark(animal) = println(animal.name, " has howled.")
47+
howl(animal) = println(animal.name, " has howled.")
4848
baa(animal) = println(animal.name, " has baaed.")
4949
#
5050
# in which case the burden of ensuring that a wolf will never baa rests upon the
@@ -75,8 +75,8 @@ nothing # hide
7575
# This difference will indeed have an impact on the time of code execution.
7676
# On my i5-8279U CPU, the difference (as measured by BenchmarkTools) is
7777
using BenchmarkTools
78-
@btime energy(a);
79-
@btime energy(b);
78+
@benchmark energy(a)
79+
@benchmark energy(b)
8080
# Which nicely demonstrates that the choice of types affects performance. Does it mean that we should always use `Tuples` instead of `Arrays`? Surely not, it is just that each is better for different use-cases. Using Tuples means that the compiler will compile a special function for each length of tuple and each combination of types of items it contains, which is clearly wasteful.
8181

8282
# # Julia's type system

0 commit comments

Comments
 (0)