<s> from bcc import BPF <EOL> from ctypes import c_int , c_ulonglong <EOL> import random <EOL> import time <EOL> from unittest import main , TestCase <EOL> class TestHistogram ( TestCase ) : <EOL> def test_simple ( self ) : <EOL> b = BPF ( text = """<STR_LIT>""" ) <EOL> for i in range ( <NUM_LIT:0> , <NUM_LIT:32> ) : <EOL> for j in range ( <NUM_LIT:0> , random . randint ( <NUM_LIT:1> , <NUM_LIT:10> ) ) : <EOL> try : del b [ "<STR_LIT>" ] [ c_ulonglong ( <NUM_LIT:1> << i ) ] <EOL> except : pass <EOL> b [ "<STR_LIT>" ] . print_log2_hist ( ) <EOL> for i in range ( <NUM_LIT:32> , <NUM_LIT:64> ) : <EOL> for j in range ( <NUM_LIT:0> , random . randint ( <NUM_LIT:1> , <NUM_LIT:10> ) ) : <EOL> try : del b [ "<STR_LIT>" ] [ c_ulonglong ( <NUM_LIT:1> << i ) ] <EOL> except : pass <EOL> b [ "<STR_LIT>" ] . print_log2_hist ( ) <EOL> def test_struct ( self ) : <EOL> b = BPF ( text = """<STR_LIT>""" ) <EOL> for i in range ( <NUM_LIT:0> , <NUM_LIT:64> ) : <EOL> for j in range ( <NUM_LIT:0> , random . randint ( <NUM_LIT:1> , <NUM_LIT:10> ) ) : <EOL> try : del b [ "<STR_LIT>" ] [ c_ulonglong ( <NUM_LIT:1> << i ) ] <EOL> except : pass <EOL> try : del b [ "<STR_LIT>" ] [ c_ulonglong ( <NUM_LIT:1> << i ) ] <EOL> except : pass <EOL> b [ "<STR_LIT>" ] . print_log2_hist ( ) <EOL> def test_chars ( self ) : <EOL> b = BPF ( text = """<STR_LIT>""" ) <EOL> for i in range ( <NUM_LIT:0> , <NUM_LIT:100> ) : time . sleep ( <NUM_LIT> ) <EOL> b [ "<STR_LIT>" ] . print_log2_hist ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
