memory heap
343 subscribers
2.31K photos
471 videos
52 files
2.94K links
science ∩ art = wonder

all memory blocks here are allocated by @a_v_p

GitHub: https://github.com/artyom-poptsov
Mastodon: https://fosstodon.org/@avp

https://memory-heap.org/~avp/
Download Telegram
Пример профилирования ДКА в Guile-INI 0.3.0 через Guile-SMC профилировщик.

Тестовая программа:
$ cat test.scm 
#!/usr/bin/guile-3.0 \
-L modules -e main -s
!#

(use-modules (ice-9 pretty-print)
(oop goops)
(logging logger)
(smc core log)
(ini))

(define (main args)
(log-clear-handlers!)
(log-add-handler! (make <port-log/us>
#:port (open-output-file "ini.log")))
(let ((data (ini->scm (current-input-port) #:debug-mode? #t)))
(pretty-print data)
(scm->ini data)))

Запуск парсера с выводом лога в файл:
$ cat /etc/php/7.4/apache2/php.ini | ./test.scm

Лог:
$ wc ini.log 
3528 21168 280750 ini.log
$ head ini.log
2022-01-07 17:06:27.338353 (DEBUG): [*] -> [read]
2022-01-07 17:06:27.339380 (DEBUG): [read] -> [read_section_title]
2022-01-07 17:06:27.339982 (DEBUG): [read_section_title] -> [read_section_content]
2022-01-07 17:06:27.340274 (DEBUG): [read_section_content] -> [read_comment]
2022-01-07 17:06:27.340710 (DEBUG): [read_comment] -> [read_section_content]
2022-01-07 17:06:27.340888 (DEBUG): [read_section_content] -> [read_comment]
2022-01-07 17:06:27.341363 (DEBUG): [read_comment] -> [read_section_content]
2022-01-07 17:06:27.341504 (DEBUG): [read_section_content] -> [read_comment]
2022-01-07 17:06:27.341728 (DEBUG): [read_comment] -> [read_section_content]
2022-01-07 17:06:27.341860 (DEBUG): [read_section_content] -> [read_comment]

Собственно профилирование:
$ smc profile ini.log
Total transitions: 3528
Total time: 630510 us
Stats:
read_comment: 416994 us (66.1360 %)
read_section_content: 153088 us (24.2800 %)
read_section_property_value: 17230 us (2.7327 %)
read_section_property_key: 16376 us (2.5973 %)
trim_section_property_key: 14990 us (2.3774 %)
trim_section_property_value: 6673 us (1.0583 %)
read_section_title: 4132 us (.6553 %)
read: 1027 us (.1629 %)

#guile #smc #dev #lisp #fsm #profiling