Skip to content

Commit 99a8000

Browse files
committed
Fix numbering in the Erlang prompt
1 parent 664a602 commit 99a8000

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ The simplest way to use this function is to look at the total number of calls an
457457
To do this, we group all calls under one key, e.g. `total`:
458458

459459
```erlang
460-
20> tr:call_stat(fun(_) -> total end).
460+
21> tr:call_stat(fun(_) -> total end).
461461
#{total => {4,7216,7216}}
462462
```
463463

@@ -470,7 +470,7 @@ For nested calls we only take into account the outermost call, so this means tha
470470
Let's see how this looks like for individual steps - we can group the stats by the function argument:
471471

472472
```erlang
473-
21> tr:call_stat(fun(#tr{data = [N]}) -> N end).
473+
22> tr:call_stat(fun(#tr{data = [N]}) -> N end).
474474
#{0 => {1,1952,1952},
475475
1 => {1,3983,2031},
476476
2 => {1,5764,1781},
@@ -480,7 +480,7 @@ Let's see how this looks like for individual steps - we can group the stats by t
480480
You can use the provided function to do filtering as well:
481481

482482
```erlang
483-
22> tr:call_stat(fun(#tr{data = [N]}) when N < 3 -> N end).
483+
23> tr:call_stat(fun(#tr{data = [N]}) when N < 3 -> N end).
484484
#{0 => {1,1952,1952},1 => {1,3983,2031},2 => {1,5764,1781}}
485485
```
486486

@@ -489,7 +489,7 @@ You can use the provided function to do filtering as well:
489489
You can sort the call stat by accumulated time (descending) with `tr:sorted_call_stat/1`:
490490

491491
```erlang
492-
23> tr:sorted_call_stat(fun(#tr{data = [N]}) -> N end).
492+
24> tr:sorted_call_stat(fun(#tr{data = [N]}) -> N end).
493493
[{3,1,7216,1452},
494494
{2,1,5764,1781},
495495
{1,1,3983,2031},
@@ -501,7 +501,7 @@ To pretty-print it, use `tr:print_sorted_call_stat/2`.
501501
The second argument limits the table row number, e.g. we can only print the top 3 items:
502502

503503
```erlang
504-
24> tr:print_sorted_call_stat(fun(#tr{data = [N]}) -> N end, 3).
504+
25> tr:print_sorted_call_stat(fun(#tr{data = [N]}) -> N end, 3).
505505
3 1 7216 1452
506506
2 1 5764 1781
507507
1 1 3983 2031
@@ -518,20 +518,20 @@ As an example, let's trace the call to a function which calculates the 4th eleme
518518
in a recursive way. The `trace` table should be empty, so let's clean it up first:
519519

520520
```erlang
521-
25> tr:clean().
521+
26> tr:clean().
522522
ok
523-
26> tr:trace([tr_SUITE]).
523+
27> tr:trace([tr_SUITE]).
524524
ok
525-
27> tr_SUITE:fib(4).
525+
28> tr_SUITE:fib(4).
526526
3
527-
28> tr:stop_tracing().
527+
29> tr:stop_tracing().
528528
ok
529529
```
530530

531531
Now it is possible to print the most time consuming call trees that repeat at least twice:
532532

533533
```erlang
534-
29> tr:top_call_trees().
534+
30> tr:top_call_trees().
535535
[{13,2,
536536
#node{module = tr_SUITE,function = fib,
537537
args = [2],
@@ -569,23 +569,23 @@ As an exercise, try calling `tr:top_call_trees(#{min_count => 1000})` for `fib(2
569569
To get the current table name, use `tr:tab/0`:
570570

571571
```erlang
572-
30> tr:tab().
572+
31> tr:tab().
573573
trace
574574
```
575575

576576
To switch to a new table, use `tr:set_tab/1`. The table need not exist.
577577

578578
```erlang
579-
31> tr:set_tab(tmp).
579+
32> tr:set_tab(tmp).
580580
ok
581581
```
582582

583583
Now you can collect traces to the new table without changing the original one.
584584

585585
```erlang
586-
32> tr:trace([lists]), lists:seq(1, 10), tr:stop_tracing().
586+
33> tr:trace([lists]), lists:seq(1, 10), tr:stop_tracing().
587587
ok
588-
33> tr:select().
588+
34> tr:select().
589589
[#tr{index = 1, pid = <0.175.0>, event = call,
590590
mfa = {lists, ukeysort, 2},
591591
data = [1,
@@ -598,7 +598,7 @@ ok
598598
You can dump a table to file with `tr:dump/1` - let's dump the `tmp` table:
599599
600600
```erlang
601-
34> tr:dump("tmp.ets").
601+
35> tr:dump("tmp.ets").
602602
ok
603603
```
604604

0 commit comments

Comments
 (0)