Exemplo n.º 1
0
    def test_deserialize(self):
        p = ProfileV1(copy.deepcopy(self.test_data))
        s = p.serialize()
        fobj = io.BytesIO(s)
        p2 = ProfileV1.deserialize(fobj)

        self.assertEqual(p2.data, self.test_data)
Exemplo n.º 2
0
    def test_saveFromRendered(self):
        p = ProfileV1(copy.deepcopy(self.test_data))
        s = Profile(p).render()

        with tempfile.NamedTemporaryFile() as f:
            Profile.saveFromRendered(s, filename=f.name)
            p2 = ProfileV1.deserialize(open(f.name))

        self.assertEqual(p2.data, self.test_data)
Exemplo n.º 3
0
    def test_deserialize(self):
        p = ProfileV1(copy.deepcopy(self.test_data))
        s = p.serialize()
        fobj = io.BytesIO(s)
        p2 = ProfileV1.deserialize(fobj)

        self.assertEqual(p2.data, self.test_data)
Exemplo n.º 4
0
    def test_deserialize(self):
        p = ProfileV2.upgrade(ProfileV1(copy.deepcopy(self.test_data)))
        s = p.serialize()
        fobj = io.BytesIO(s)
        p2 = ProfileV2.deserialize(fobj)

        l = list(p2.getCodeForFunction('fn1'))
        l2 = self.test_data['functions']['fn1']['data']
        self.assertEqual(l, l2)
Exemplo n.º 5
0
    def test_saveFromRendered(self):
        p = ProfileV1(copy.deepcopy(self.test_data))
        s = Profile(p).render()

        with tempfile.NamedTemporaryFile() as f:
            Profile.saveFromRendered(s, filename=f.name)
            p2 = ProfileV1.deserialize(open(f.name))

        self.assertEqual(p2.data, self.test_data)
Exemplo n.º 6
0
 def test_getFunctions(self):
     p = ProfileV2.upgrade(ProfileV1(copy.deepcopy(self.test_data)))
     self.assertEqual(
         p.getFunctions(), {
             'fn1': {
                 'counters': {
                     'cycles': 45.0,
                     'branch-misses': 10.0
                 },
                 'length': 2
             }
         })
Exemplo n.º 7
0
 def test_serialize(self):
     p = ProfileV2.upgrade(ProfileV1(copy.deepcopy(self.test_data)))
     with tempfile.NamedTemporaryFile() as f:
         s = p.serialize(f.name)
         self.assertTrue(ProfileV2.checkFile(f.name))
Exemplo n.º 8
0
# Check that we can import profiles into a test DB
#
# We first construct a temporary LNT instance.
# RUN: rm -rf %t.install
# RUN: lnt create %t.install

# Import the test set
# RUN: lnt import %t.install %S/Inputs/profile-report.json \
# RUN:   --commit=1 --show-sample-count > %t2.log
# RUN: ls %t.install/data/profiles
# RUN: python %s %t.install

import os, sys, glob
from lnt.testing.profile.profilev1impl import ProfileV1

profile = glob.glob('%s/data/profiles/*.lntprof' % sys.argv[1])[0]
assert ProfileV1.checkFile(profile)
Exemplo n.º 9
0
 def test_serialize(self):
     p = ProfileV1(copy.deepcopy(self.test_data))
     with tempfile.NamedTemporaryFile() as f:
         s = p.serialize(f.name)
         self.assertTrue(ProfileV1.checkFile(f.name))