Skip to content

Instantly share code, notes, and snippets.

@samth
Created May 27, 2021 18:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save samth/ff84e45a64cc84ff68c461d6d1837e4e to your computer and use it in GitHub Desktop.
#lang racket
(require sugar)
(define (go file h)
(define lines (file->lines file))
(match-define (list header chunks ... summary) (filter-split lines (lambda (l) (equal? l ""))))
(define p
(for/list ([l chunks])
(define size (regexp-match "leak of (.+) .* in (.+) object" (car l)))
(list (and size (map string->number (cdr size)))
(filter values
(for/list ([i (cdr l)])
(define fn (regexp-match #rx" in (.+) \\(" i))
(and fn (second fn)))))))
(for/fold ([h h]) ([i p])
(hash-update h (second i) (match-lambda [(list b n) (list (+ (first (car i)) b)
(+ (second (car i)) n))])
(list 0 0))))
(define h
(for/fold ([h (hash)])
([i (find-files (lambda (v) (regexp-match "^racket-asan" v)))])
(go i h)))
(sort (hash-map h list) >
#:key (compose car second))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment