def benchmark(post_count, iterations): print("Running benchmark with %d posts, %d iterations" % (post_count, iterations)) times = [] # setup blog setup() # load content lorem = load_content() # create posts for i in range(post_count): post.create("Post %d" % i).write(tags="tag #%d" % i, content=lorem) for i in range(iterations): print("Iteration %d..." % i) start = datetime.datetime.now() cmdline.build() times.append(datetime.datetime.now() - start) print(times[-1]) # cleanup test dir cleanup() print("Average time: %s" % (sum(times, datetime.timedelta(0)) / len(times)))
def build_theme(use_theme): # setup blog setup() # write conf file with given theme writer.write_conf_file(theme=use_theme) # load content lorem = load_content() # create posts post.create("This is a post", datetime.date(2010, 10, 1)).write(tags="tag #1, tag #2", content=lorem) post.create("This is another post", datetime.date(2010, 11, 2)).write(tags="tag #1", content=lorem) post.create("This is yet another post", datetime.date(2010, 12, 3)).write(tags="tag #2", content=lorem) # create pages page.create("First page").write() page.create("Second page").write() # build cmdline.build()
def benchmark(post_count, iterations): print("Running benchmark with %d posts, %d iterations" % (post_count, iterations)) times = [] # setup blog setup() # load content lorem = load_content() # create posts for i in range(post_count): post.create("Post %d" % i).write( tags="tag #%d" % i, content=lorem) for i in range(iterations): print("Iteration %d..." % i) start = datetime.datetime.now() cmdline.build() times.append(datetime.datetime.now() - start) print(times[-1]) # cleanup test dir cleanup() print("Average time: %s" % (sum(times, datetime.timedelta(0)) / len(times)))
def build_theme(use_theme): # setup blog setup() # write conf file with given theme writer.write_conf_file(theme=use_theme) # load content lorem = load_content() # create posts post.create("This is a post", datetime.date(2010, 10, 1)).write( tags="tag #1, tag #2", content=lorem) post.create("This is another post", datetime.date(2010, 11, 2)).write( tags="tag #1", content=lorem) post.create("This is yet another post", datetime.date(2010, 12, 3)).write( tags="tag #2", content=lorem) # create pages page.create("First page").write() page.create("Second page").write() # build cmdline.build()
def build_all_themes(): ''' Builds all themes ''' # remove previous theme build output if any shutil.rmtree("themes", True) for theme in OTHER_THEMES: print("Building theme %s" % (theme,)) update_conf(theme) cmdline.build() move_theme(theme) update_conf(DEFAULT_THEME) cmdline.build()
def build(self): print("") self.assertEquals(0, cmdline.build())