Skip to content

Instantly share code, notes, and snippets.

@if1live
Created April 2, 2015 06:05
Show Gist options
  • Save if1live/c8c8d5cf4429e4be07c5 to your computer and use it in GitHub Desktop.
Save if1live/c8c8d5cf4429e4be07c5 to your computer and use it in GitHub Desktop.
Creation time of python markdown object
#!/usr/bin/env python
#-*- coding: utf-8 -*-
'''
output sample
initial create : 0.0293490886688
re-create #1 : 0.00163388252258
re-create #2 : 0.00191903114319
최초 생성시에만 느리다.
'''
from markdown import Markdown
import time
markdown_extension_list = [
"abbr",
"attr_list",
"def_list",
"fenced_code",
"tables",
"smart_strong",
"admonition",
"codehilite",
"nl2br",
"sane_lists",
"toc",
"wikilinks",
]
a = time.time()
md = Markdown(extensions=markdown_extension_list)
b = time.time()
md = Markdown(extensions=markdown_extension_list)
c = time.time()
md = Markdown(extensions=markdown_extension_list)
d = time.time()
print("initial create : {}".format(b - a))
print("re-create #1 : {}".format(c - b))
print("re-create #2 : {}".format(d - c))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment