def test_sorting():
    stats = RecordingStatistics(mock_code('foo'))
    stats1 = RecordingStatistics(mock_code('bar'))
    stats2 = RecordingStatistics(mock_code('baz'))
    stats3 = RecordingStatistics(mock_code('qux'))
    stats.add_child(stats1.code, stats1)
    stats.add_child(stats2.code, stats2)
    stats.add_child(stats3.code, stats3)
    stats.deep_time = 100
    stats1.deep_time = 20
    stats1.own_hits = 3
    stats2.deep_time = 30
    stats2.own_hits = 2
    stats3.deep_time = 40
    stats3.own_hits = 4
    assert stats.sorted() == [stats3, stats2, stats1]
    assert stats.sorted(by_own_hits) == [stats3, stats1, stats2]
    assert stats.sorted(~by_own_hits) == [stats2, stats1, stats3]
    assert stats.sorted(by_deep_time_per_call) == [stats2, stats3, stats1]
    assert stats.sorted(by_own_time_per_call) == [stats2, stats3, stats1]
    assert stats.sorted(by_name) == [stats1, stats2, stats3]
dataset/ETHPy150Open what-studio/profiling/test/test_stats.py/test_sorting/original