Esempio n. 1
0
    def test_numpy(self, amount=10):
    
       
        
        for iter in range(amount):
            
            # Random struct            
            s = Generator.create_struct()
            self._s = s
            
            # Text with numpy on writing
            self.enable_np()            
            text = ssdf.saves(s)
            #
            self.disable_np()
            s2 = ssdf.loads(text)
            text = ssdf.saves(s2)
            #
            self.enable_np()
            s3 = ssdf.loads(text)
#             if not compare(s, s2):
#                 print('Test text failed after %i iterations.' % iter)
#                 break  
            if not compare(s, s3):
                print('Test text failed after %i iterations.' % iter)
                break  
            
            # Binary with numpy on writing
            self.enable_np()
            bb = ssdf.saveb(s)
            #            
            self.disable_np()
            s2 = ssdf.loadb(bb)
            bb = ssdf.saveb(s2)
            #
            self.enable_np()
            s3 = ssdf.loadb(bb)
#             if not compare(s, s2):
#                 print('Test bin failed after %i iterations.' % iter)
#                 break  
            if not compare(s, s3):
                print('Test bin failed after %i iterations.' % iter)
                break  
            
            print('%i tests successfull' % iter)
            time.sleep(0.001)
        
#             # Text with numpy on writing
#             self.disable_np()
#             s = Generator.create_struct()
#             text = ssdf.saves(s)
#             #
#             self.enable_np()
#             s2 = ssdf.loads(text)
#             text = ssdf.saves(s2)
#             #
#             self.disable_np()
#             s3 = ssdf.loads(text)
#             if not compare(s, s3):
#                 print('Test text failed after %i iterations.' % iter)
#                 break  
#             
#             # Binary with numpy on writing
#             self.disable_np()
#             s = Generator.create_struct()
#             bb = ssdf.saveb(s)
#             #            
#             self.enable_np()
#             s2 = ssdf.loadb(bb)
#             bb = ssdf.saveb(s2)
#             #
#             self.disable_np()
#             s3 = ssdf.loadb(bb)
#             if not compare(s, s3):
#                 print('Test bin failed after %i iterations.' % iter)
#                 break  
        
        # Finish
        self.enable_np()
Esempio n. 2
0
    def test_numpy(self, amount=10):

        for iter in range(amount):

            # Random struct
            s = Generator.create_struct()
            self._s = s

            # Text with numpy on writing
            self.enable_np()
            text = ssdf.saves(s)
            #
            self.disable_np()
            s2 = ssdf.loads(text)
            text = ssdf.saves(s2)
            #
            self.enable_np()
            s3 = ssdf.loads(text)
            #             if not compare(s, s2):
            #                 print('Test text failed after %i iterations.' % iter)
            #                 break
            if not compare(s, s3):
                print('Test text failed after %i iterations.' % iter)
                break

            # Binary with numpy on writing
            self.enable_np()
            bb = ssdf.saveb(s)
            #
            self.disable_np()
            s2 = ssdf.loadb(bb)
            bb = ssdf.saveb(s2)
            #
            self.enable_np()
            s3 = ssdf.loadb(bb)
            #             if not compare(s, s2):
            #                 print('Test bin failed after %i iterations.' % iter)
            #                 break
            if not compare(s, s3):
                print('Test bin failed after %i iterations.' % iter)
                break

            print('%i tests successfull' % iter)
            time.sleep(0.001)


#             # Text with numpy on writing
#             self.disable_np()
#             s = Generator.create_struct()
#             text = ssdf.saves(s)
#             #
#             self.enable_np()
#             s2 = ssdf.loads(text)
#             text = ssdf.saves(s2)
#             #
#             self.disable_np()
#             s3 = ssdf.loads(text)
#             if not compare(s, s3):
#                 print('Test text failed after %i iterations.' % iter)
#                 break
#
#             # Binary with numpy on writing
#             self.disable_np()
#             s = Generator.create_struct()
#             bb = ssdf.saveb(s)
#             #
#             self.enable_np()
#             s2 = ssdf.loadb(bb)
#             bb = ssdf.saveb(s2)
#             #
#             self.disable_np()
#             s3 = ssdf.loadb(bb)
#             if not compare(s, s3):
#                 print('Test bin failed after %i iterations.' % iter)
#                 break

# Finish
        self.enable_np()
Esempio n. 3
0
 def run(self, amount=100000):
     self._stop = False
     t0 = time.time()
     maxtests = amount
     
     while len(self._tests) < maxtests and not self._stop:
         
         # Create struct
         s = Generator.create_struct()
         n = ssdf.count(s)
         self._s = s
         
         # times
         times = []
         sizes = []
         
         # Test text
         t1 = time.time()
         text = ssdf.saves(s)
         times.append(time.time()-t1)
         #
         t1 = time.time()
         s2 = ssdf.loads(text)
         times.append(time.time()-t1)
         #
         if not compare(s, s2):
             print('Test text failed after %i iterations.' % len(self._tests))
             break
         
         # Test binary
         t1 = time.time()
         bb = ssdf.saveb(s)
         times.append(time.time()-t1)
         #
         t1 = time.time()
         s2 = ssdf.loadb(bb)
         times.append(time.time()-t1)
         #
         if not compare(s, s2):
             print('Test bin failed after %i iterations.' % len(self._tests))
             break
         
         # Test text file
         fname = homedir+'projects/ssdftest.ssdf'
         t1 = time.time()
         ssdf.save(fname, s)
         times.append(time.time()-t1)
         #
         t1 = time.time()
         s2 = ssdf.load(fname)
         times.append(time.time()-t1)
         sizes.append(os.stat(fname).st_size)
         #
         if not compare(s, s2):
             print('Test text-file failed after %i iterations.' % len(self._tests))
             break
             
         # Test binary file
         fname = homedir+'projects/ssdftest.bsdf'
         t1 = time.time()
         ssdf.save(fname, s)
         times.append(time.time()-t1)
         #
         t1 = time.time()
         s2 = ssdf.load(fname)
         times.append(time.time()-t1)
         sizes.append(os.stat(fname).st_size)
         #
         if not compare(s, s2):
             print('Test bin-file failed after %i iterations.' % len(self._tests))
             break
         
         # Success
         self._tests.append( (n, times, sizes) )
         print('%i tests successfull' % len(self._tests))
         time.sleep(0.001)
Esempio n. 4
0
    def run(self, amount=100000):
        self._stop = False
        t0 = time.time()
        maxtests = amount

        while len(self._tests) < maxtests and not self._stop:

            # Create struct
            s = Generator.create_struct()
            n = ssdf.count(s)
            self._s = s

            # times
            times = []
            sizes = []

            # Test text
            t1 = time.time()
            text = ssdf.saves(s)
            times.append(time.time() - t1)
            #
            t1 = time.time()
            s2 = ssdf.loads(text)
            times.append(time.time() - t1)
            #
            if not compare(s, s2):
                print('Test text failed after %i iterations.' %
                      len(self._tests))
                break

            # Test binary
            t1 = time.time()
            bb = ssdf.saveb(s)
            times.append(time.time() - t1)
            #
            t1 = time.time()
            s2 = ssdf.loadb(bb)
            times.append(time.time() - t1)
            #
            if not compare(s, s2):
                print('Test bin failed after %i iterations.' %
                      len(self._tests))
                break

            # Test text file
            fname = homedir + 'projects/ssdftest.ssdf'
            t1 = time.time()
            ssdf.save(fname, s)
            times.append(time.time() - t1)
            #
            t1 = time.time()
            s2 = ssdf.load(fname)
            times.append(time.time() - t1)
            sizes.append(os.stat(fname).st_size)
            #
            if not compare(s, s2):
                print('Test text-file failed after %i iterations.' %
                      len(self._tests))
                break

            # Test binary file
            fname = homedir + 'projects/ssdftest.bsdf'
            t1 = time.time()
            ssdf.save(fname, s)
            times.append(time.time() - t1)
            #
            t1 = time.time()
            s2 = ssdf.load(fname)
            times.append(time.time() - t1)
            sizes.append(os.stat(fname).st_size)
            #
            if not compare(s, s2):
                print('Test bin-file failed after %i iterations.' %
                      len(self._tests))
                break

            # Success
            self._tests.append((n, times, sizes))
            print('%i tests successfull' % len(self._tests))
            time.sleep(0.001)