Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 9 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# NetLogo Profiler Extension

## Building
Expand Down Expand Up @@ -49,7 +48,7 @@ profiler:reset ;; clear the data
```

Another way to use the profiler is to export its raw data using
the [`csv` extension](https://ccl.northwestern.edu/netlogo/docs/csv.html)
the [`csv` extension](https://docs.netlogo.org/csv.html)
and the `profiler:data` primitive:

```NetLogo
Expand Down Expand Up @@ -83,7 +82,6 @@ REPRODUCE-WOLVES,1039,5.599509,5.599509

Thanks to Roger Peppe for his contributions to the code.


## Primitives

[`profiler:calls`](#profilercalls)
Expand All @@ -95,50 +93,40 @@ Thanks to Roger Peppe for his contributions to the code.
[`profiler:report`](#profilerreport)
[`profiler:data`](#profilerdata)


### `profiler:calls`

```NetLogo
profiler:calls procedure-name
```


Reports the number of times that *procedure-name* was called. If
*procedure-name* is not defined, then reports 0.


Reports the number of times that _procedure-name_ was called. If
_procedure-name_ is not defined, then reports 0.

### `profiler:exclusive-time`

```NetLogo
profiler:exclusive-time procedure-name
```


Reports the exclusive time, in milliseconds, that
*procedure-name* was running for. Exclusive time is the time
_procedure-name_ was running for. Exclusive time is the time
from when the procedure was entered, until it finishes, but does not
include any time spent in other user-defined procedures which it
calls.

If *procedure-name* is not defined, then reports 0.


If _procedure-name_ is not defined, then reports 0.

### `profiler:inclusive-time`

```NetLogo
profiler:inclusive-time procedure-name
```


Reports the inclusive time, in milliseconds, that
*procedure-name* was running for. Inclusive time is the time
_procedure-name_ was running for. Inclusive time is the time
from when the procedure was entered, until it finishes.

If *procedure-name* is not defined, then reports 0.


If _procedure-name_ is not defined, then reports 0.

### `profiler:start`

Expand All @@ -148,7 +136,6 @@ profiler:start

Instructs the profiler to begin recording user-defined procedure calls.


### `profiler:stop`

```NetLogo
Expand All @@ -157,7 +144,6 @@ profiler:stop

Instructs the profiler to stop recording user-defined procedure calls.


### `profiler:reset`

```NetLogo
Expand All @@ -166,14 +152,12 @@ profiler:reset

Instructs the profiler to erase all collected data.


### `profiler:report`

```NetLogo
profiler:report
```


Reports a string containing a breakdown of all user-defined procedure
calls. The `Calls` column contains the number of times a
user-defined procedure was called. The `Incl T(ms)` column
Expand Down Expand Up @@ -205,26 +189,21 @@ Name Calls Incl T(ms) Excl T(ms) Excl/calls
CALLTHEM 13 26.066 19.476 1.498
```



### `profiler:data`

```NetLogo
profiler:data
```


Reports a list of lists containing the results of the profiler in a format that is suitable
for exporting with the [`csv` extension](https://ccl.northwestern.edu/netlogo/docs/csv.html).
for exporting with the [`csv` extension](https://docs.netlogo.org/csv.html).

The first sublist contains the name of the data columns: `procedure`, `calls`, `inclusive_time` and
`exclusive_time`. This is followed by one sublist containing the profiler data for each user-defined
procedure. The reported times are in milliseconds.



## Terms of Use

[![CC0](http://i.creativecommons.org/p/zero/1.0/88x31.png)](http://creativecommons.org/publicdomain/zero/1.0/)

The NetLogo profiler extension is in the public domain. To the extent possible under law, Uri Wilensky has waived all copyright and related or neighboring rights.
The NetLogo profiler extension is in the public domain. To the extent possible under law, Uri Wilensky has waived all copyright and related or neighboring rights.
3 changes: 1 addition & 2 deletions USING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ profiler:reset ;; clear the data
```

Another way to use the profiler is to export its raw data using
the [`csv` extension](https://ccl.northwestern.edu/netlogo/docs/csv.html)
the [`csv` extension](https://docs.netlogo.org/csv.html)
and the `profiler:data` primitive:

```NetLogo
Expand Down Expand Up @@ -71,4 +71,3 @@ REPRODUCE-WOLVES,1039,5.599509,5.599509
```

Thanks to Roger Peppe for his contributions to the code.

131 changes: 131 additions & 0 deletions documentation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
extensionName: profiler
icon: i-oui-app-search-profiler
filesToIncludeInManual:
- USING.md
- primitives
markdownTemplate: |2

# NetLogo Profiler Extension

{{> BUILDING.md}}

{{> USING.md}}

## Primitives

{{#contents}}{{#prims}}
[`{{name}}`](#{{primitive.extensionName}}{{primitive.name}})
{{/prims}}{{/contents}}

{{#primitives}}
{{> primTemplate}}
{{/primitives}}

{{> LICENSE.md}}
primTemplate: |2

### `{{name}}`

```NetLogo
{{#examples}}
{{primitive.fullName}}{{#args}} {{name}}{{/args}}
{{/examples}}
```

{{{description}}}
primitives:
- name: calls
type: reporter
returns: number
arguments:
- name: procedure-name
type: string
description: |
Reports the number of times that *procedure-name* was called. If
*procedure-name* is not defined, then reports 0.

- name: exclusive-time
type: reporter
returns: number
arguments:
- name: procedure-name
type: string
description: |
Reports the exclusive time, in milliseconds, that
*procedure-name* was running for. Exclusive time is the time
from when the procedure was entered, until it finishes, but does not
include any time spent in other user-defined procedures which it
calls.

If *procedure-name* is not defined, then reports 0.

- name: inclusive-time
type: reporter
returns: number
arguments:
- name: procedure-name
type: string
description: |
Reports the inclusive time, in milliseconds, that
*procedure-name* was running for. Inclusive time is the time
from when the procedure was entered, until it finishes.

If *procedure-name* is not defined, then reports 0.

- name: start
type: command
description: Instructs the profiler to begin recording user-defined procedure calls.

- name: stop
type: command
description: Instructs the profiler to stop recording user-defined procedure calls.

- name: reset
type: command
description: Instructs the profiler to erase all collected data.

- name: report
type: reporter
returns: string
description: |
Reports a string containing a breakdown of all user-defined procedure
calls. The `Calls` column contains the number of times a
user-defined procedure was called. The `Incl T(ms)` column
is the total time, in milliseconds, it took for the call to complete,
including the time spent in other user-defined procedures. The
`Excl T(ms)` column is the total time, in milliseconds,
spent within that user-defined procedure, not counting other
user-define procedures it called. The <code>Excl/calls</code> column
is an estimate of the time, in milliseconds, spent in that
user-defined procedure for each call.

Here is example output:

```
Sorted by Exclusive Time
Name Calls Incl T(ms) Excl T(ms) Excl/calls
CALLTHEM 13 26.066 19.476 1.498
CALLME 13 6.413 6.413 0.493
REPORTME 13 0.177 0.177 0.014

Sorted by Inclusive Time
Name Calls Incl T(ms) Excl T(ms) Excl/calls
CALLTHEM 13 26.066 19.476 1.498
CALLME 13 6.413 6.413 0.493
REPORTME 13 0.177 0.177 0.014

Sorted by Number of Calls
Name Calls Incl T(ms) Excl T(ms) Excl/calls
CALLTHEM 13 26.066 19.476 1.498
```

- name: data
type: reporter
returns: list
description: |
Reports a list of lists containing the results of the profiler in a format that is suitable
for exporting with the [`csv` extension](https://ccl.northwestern.edu/netlogo/docs/csv.html).

The first sublist contains the name of the data columns: `procedure`, `calls`, `inclusive_time` and
`exclusive_time`. This is followed by one sublist containing the profiler data for each user-defined
procedure. The reported times are in milliseconds.