<commit_before>#!/usr/bin/python

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# Analyze the ++/-- DOMWINDOW in a TBPL log.

import re
import sys

winPatt = re.compile('\d\d:\d\d:\d\d\W+INFO -  (..)DOMWINDOW == (\d+).*\[pid = (\d+)\] \[serial = (\d+)\]')


#11:28:12     INFO -  ++DOMWINDOW == 1 (0xa7a75c00) [pid = 2238] [serial = 1] [outer = (nil)]

live = set([])

for l in sys.stdin:
    m = winPatt.match(l)
    if not m:
        continue
    isNew = m.group(1) == '++'
    assert isNew or m.group(1) == '--'

    numLive = int(m.group(2))
    pid = int(m.group(3))
    serial = int(m.group(4))

    #print isNew, 'XXX serial=' , serial, 'XXX pid=', pid, 'XXX', l[:-1]

    winId = (pid, serial)

    if isNew:
        live.add(winId)
    else:
        assert winId in live
        live.remove(winId)


# Print out informatio about leaking windows.
for x in live:
    print "[pid = {0}] [serial = {1}]".format(x[0], x[1])

<commit_msg>add a function<commit_after>#!/usr/bin/python

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# Analyze the ++/-- DOMWINDOW in a TBPL log.

import re
import sys

winPatt = re.compile('\d\d:\d\d:\d\d\W+INFO -  (..)DOMWINDOW == (\d+).*\[pid = (\d+)\] \[serial = (\d+)\]')

#11:28:12     INFO -  ++DOMWINDOW == 1 (0xa7a75c00) [pid = 2238] [serial = 1] [outer = (nil)]


def findLeakers():
    live = set([])

    for l in sys.stdin:
        m = winPatt.match(l)
        if not m:
            continue
        isNew = m.group(1) == '++'
        assert isNew or m.group(1) == '--'

        numLive = int(m.group(2))
        pid = int(m.group(3))
        serial = int(m.group(4))

        #print isNew, 'XXX serial=' , serial, 'XXX pid=', pid, 'XXX', l[:-1]

        winId = (pid, serial)

        if isNew:
            live.add(winId)
        else:
            assert winId in live
            live.remove(winId)


    # Print out information about leaking windows.
    for x in live:
        print "[pid = {0}] [serial = {1}]".format(x[0], x[1])


findLeakers()
{'fraction_non_alphanumeric': 0.17830802603036877, 'fraction_numerical': 0.02776572668112798, 'mean_word_length': 2.2755681818181817, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1006524', 'n_tokens_mistral': 920, 'n_tokens_neox': 859, 'n_words': 257}