Пример #1
0
def main():   
    input = 'really-big-dump.bin'
    
    timing_bucket = Bucket()
    result_bucket = Bucket()
    
    
    def onQuery(query):
        global total
        time = query.first_result - query.timestamp
        sql = Sql(query.sql)
        timing_bucket.increment(sql, time)
        result_bucket.increment(sql, query.result_size)
        total += 1
    
    def ConnFactory():
        return MysqlConnection(onQuery)
    
    collapse_tcp_streams(read_packets(input), ConnFactory, progress)
    
    print total
    
    for sql, time, avg_time, count, median_time in timing_bucket.counts():
        total_rows, avg_rows, count_rows, median_rows = result_bucket.aggregate(sql)
        """
Пример #2
0
def find_mac(input):
    packets = islice(read_packets(input), 25000)
    buffer = []
    macs = Bucket()
    for n in range(200):
        read = packets.next()
        buffer.append(read)
        macs.increment(read.raw_data[0:6])
        macs.increment(read.raw_data[6:12])
    
    freq = macs.counts()
    return freq[0][0]