Ejemplo n.º 1
0
def benchmarkTest():
    '''Test whether asynchronous map or synchronous map is faster'''
    lines = open("book.txt").readlines()
    mappy_c = 0
    map_c = 0

    #Compute async map time on average
    before_mappy_t = datetime.datetime.now()
    for i in range(20):
        mappy_c += reduce(add, mappy(countTom, lines, 4))
    after_mappy_t = datetime.datetime.now()

    #Compute sync map time on average
    before_map_t = datetime.datetime.now()
    for i in range(20):
        map_c += reduce(add, map(countTom, lines))
    after_map_t = datetime.datetime.now()

    mappy_t = after_mappy_t - before_mappy_t
    map_t = after_map_t - before_map_t
    print "Async time: " + str(mappy_t)
    print "Sync time: " + str(map_t)
Ejemplo n.º 2
0
def benchmarkTest():
  '''Test whether asynchronous map or synchronous map is faster'''
  lines = open("book.txt").readlines()
  mappy_c = 0
  map_c = 0
  
  #Compute async map time on average
  before_mappy_t = datetime.datetime.now()
  for i in range(20):
    mappy_c += reduce(add, mappy(countTom, lines, 4))
  after_mappy_t = datetime.datetime.now()


  #Compute sync map time on average
  before_map_t = datetime.datetime.now()
  for i in range(20):
    map_c += reduce(add, map(countTom, lines))
  after_map_t = datetime.datetime.now()

  mappy_t = after_mappy_t - before_mappy_t
  map_t = after_map_t - before_map_t
  print "Async time: " + str(mappy_t)
  print "Sync time: " + str(map_t)
Ejemplo n.º 3
0
 def test_wordcount_p32(self):
   seq = range(7932)
   m = reduce(lambda x,y: x+y, mappy(square, seq, 32))
   r = reduce(lambda x,y: x+y, map(square, seq))
   assert m == r
Ejemplo n.º 4
0
 def test_wordcount_p1(self):
   seq = range(518)
   m = reduce(lambda x,y: x+y, mappy(square, seq, 1))
   r = reduce(lambda x,y: x+y, map(square, seq))
   assert m == r
Ejemplo n.º 5
0
 def test_wordcount_p32(self):
   m = reduce(lambda x,y: x+y, mappy(word_count, self.lorem_text, 32))
   assert m == self.lorem_result
Ejemplo n.º 6
0
 def test_wordcount_p32(self):
     seq = range(7932)
     m = reduce(lambda x, y: x + y, mappy(square, seq, 32))
     r = reduce(lambda x, y: x + y, map(square, seq))
     assert m == r
Ejemplo n.º 7
0
 def test_wordcount_p1(self):
     seq = range(518)
     m = reduce(lambda x, y: x + y, mappy(square, seq, 1))
     r = reduce(lambda x, y: x + y, map(square, seq))
     assert m == r