Test the performance of TreeWalker compared to other DOM walker methods. Ran each test 1000 times. Try it yourself.
Method Total ms Average ms
document.TreeWalker 911 0.911
Iterative Traverser 2945 2.945
Test the performance of TreeWalker compared to other DOM walker methods. Ran each test 1000 times. Try it yourself.
Method Total ms Average ms
document.TreeWalker 911 0.911
Iterative Traverser 2945 2.945
class Application(tornado.web.Application): | |
def __init__(self): | |
tornado.web.Application.__init__(self, handlers, **settings) | |
self.db_session = db_session | |
self.redis = redis.StrictRedis() | |
self.session_store = RedisSessionStore(self.redis) | |
class BaseHandler(tornado.web.RequestHandler): |
# -*- Encoding: utf-8 -*- | |
import base64 | |
import binascii | |
import cgi | |
import hashlib | |
import hmac | |
import logging | |
import time | |
import urllib | |
import urlparse |
"""Simple TCP server for playing Tic-Tac-Toe game. | |
Use Player-to-Player game mode based on naming auth. | |
No thoughts about distribution or pub/sub mode | |
(for monitoring or something like this). Just | |
basic functionality. | |
""" | |
import time | |
import logging |
from tornado import ioloop | |
from tornado import iostream | |
import socket | |
class Envelope(object): | |
def __init__(self, sender, rcpt, body, callback): | |
self.sender = sender | |
self.rcpt = rcpt[:] | |
self.body = body | |
self.callback = callback |
""" | |
tornado_static is a module for displaying static resources in a Tornado web | |
application. | |
It can take care of merging, compressing and giving URLs ideal renamings | |
suitable for aggressive HTTP caching. | |
(c) [email protected] | |
""" |
from django.contrib.sessions.backends.base import SessionBase, CreateError | |
from django.conf import settings | |
from django.utils.encoding import force_unicode | |
import redis | |
class SessionStore(SessionBase): | |
""" Redis store for sessions""" | |
def __init__(self, session_key=None): | |
self.redis = redis.Redis( |
#!/usr/bin/env python | |
__author__ = 'Frank Smit <[email protected]>' | |
__version__ = '0.1.0' | |
import functools | |
import psycopg2 | |
from tornado.ioloop import IOLoop, PeriodicCallback |
class MyHTTPServer(tornado.httpserver.HTTPServer): | |
_stopped = False | |
def _quit_if_ioloop_is_empty(self): | |
ioloop = tornado.ioloop.IOLoop.instance() | |
if len(ioloop._handlers) <= 1: | |
logger.info("Graceful shutdown complete. Exiting!") | |
exit(0) | |
else: | |
logger.info("Waiting for ioloop to be empty. has %d handlers left" % len(ioloop._handlers)) |