4
4
5
5
= SUBTITLE Measuring and improving run-time or compile-time performance
6
6
7
- This page is about anything to do with L < computer performance|https://en.wikipedia.org/wiki/Computer_Performance >
7
+ This page is about anything to do with L < computer performance|https://en.wikipedia.org/wiki/Computer_performance >
8
8
in the context of Perl 6.
9
9
10
10
= head1 First, clarify the problem
@@ -17,8 +17,8 @@ L<"critical 3%"|https://en.wikiquote.org/wiki/Donald_Knuth> by "profiling" as ex
17
17
Expressions of the form C < now - BEGIN now > , where C < BEGIN > is a
18
18
L < phase in the running of a Perl 6 program|/language/phasers > , provide a great idiom for timing code snippets.
19
19
20
- Using the C < m: your code goes here > L < #perl6 channel evalbot|http://doc.perl6.org/language/glossary#camelia >
21
- you can write lines like:
20
+ Use the C < m: your code goes here > L < #perl6 channel evalbot|http://doc.perl6.org/language/glossary#camelia >
21
+ to write lines like:
22
22
23
23
m: say now - INIT now
24
24
rakudo-moar 8bd7ee: OUTPUT « 0.0018558 »
@@ -28,8 +28,8 @@ because the latter occurs during L<the INIT phase|/language/phasers#INIT>.
28
28
29
29
= head2 Profile with C < prof-m: your code goes here >
30
30
31
- Entering C < prof-m: your code goes here > in the L < #perl6 channel|http://doc.perl6.org/language/glossary#IRC >
32
- invokes an evalbot that runs a Perl 6 compiler with a C < --profile > option.
31
+ Enter C < prof-m: your code goes here > in the L < #perl6 channel|http://doc.perl6.org/language/glossary#IRC >
32
+ to invoke a Perl 6 compiler with a C < --profile > option.
33
33
The evalbot's output includes a link to L < profile info|https://en.wikipedia.org/wiki/Profiling_(computer_programming) > :
34
34
35
35
= begin code :allow< L >
@@ -84,7 +84,7 @@ Start by identifying the L<"critical 3%"|https://en.wikiquote.org/wiki/Donald_Kn
84
84
85
85
= head2 Line by line
86
86
87
- A quick, fun and frequently very productive way to try improve code line-by-line is to collaborate with
87
+ A quick, fun, productive way to try improve code line-by-line is to collaborate with
88
88
others using the L < #perl6|http://doc.perl6.org/language/glossary#IRC > evalbot
89
89
L < camelia|http://doc.perl6.org/language/glossary#camelia > .
90
90
@@ -144,16 +144,16 @@ that array:
144
144
The assignment of all the lines in 'largefile.txt' to C < @lines > all at once is called "eager" assignment,
145
145
the opposite of "lazy".
146
146
147
- But if 'largefile.txt' contains a million very long lines you just used up a ton of memory and it may
147
+ If 'largefile.txt' contains a million very long lines you just used up a ton of memory and it may
148
148
well take quite a while before your code starts to do something with the first line.
149
149
150
- A "lazy" approach often performs much better:
150
+ A "lazy" approach often performs much better than an eager one :
151
151
152
152
for 'largefile.txt'.IO.lines -> $line {
153
153
# do something with $line
154
154
}
155
155
156
- This loop pulls just one line from 'largefile.txt', immediately processes it, then gets the next, and so on.
156
+ This loop pulls a line from 'largefile.txt', immediately processes it, then gets the next, and so on.
157
157
158
158
= head3 Change sequential/blocking code to parallel/non-blocking
159
159
@@ -189,7 +189,7 @@ Perl 5's compiler can be treated as a C lib. Mix in Perl 6 types, the L<MOP|/lan
189
189
programming that someone else has done for you, and the upshot is that you can conveniently
190
190
L < use Perl 5 modules in Perl 6|http://stackoverflow.com/a/27206428/1077672 > .
191
191
192
- More generally, Perl 6 is designed to be able to smoothly interop with other languages and there are a number
192
+ More generally, Perl 6 is designed for smooth interop with other languages and there are a number
193
193
of L < modules aimed at providing convenient use of libs from other langs|http://modules.perl6.org/#q=inline > .
194
194
195
195
= head2 Make the Rakudo compiler generate faster code
0 commit comments