[z3-checkins] r33137 - in z3/deliverance/branches/packaged/deliverance: . test-data/nycsr
cabraham at codespeak.net
cabraham at codespeak.net
Tue Oct 10 22:06:08 CEST 2006
Author: cabraham
Date: Tue Oct 10 22:06:00 2006
New Revision: 33137
Added:
z3/deliverance/branches/packaged/deliverance/test-data/nycsr/nycsr_speed.html
z3/deliverance/branches/packaged/deliverance/test_speed.py
Log:
Added a test to compare the speeds of the two renderers.
Added: z3/deliverance/branches/packaged/deliverance/test-data/nycsr/nycsr_speed.html
==============================================================================
--- (empty file)
+++ z3/deliverance/branches/packaged/deliverance/test-data/nycsr/nycsr_speed.html Tue Oct 10 22:06:00 2006
@@ -0,0 +1,441 @@
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>The New York City Streets Renaissance</title>
+ <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
+ <meta name="author" content="New York City Streets Renaissance" />
+ <meta name="description" content="" />
+ <meta name="keywords" content="" />
+ <meta name="generator" content="BBEdit 8.2" />
+ <meta name="MSSmartTagsPreventParsing" content="true" />
+ <meta name="robots" content="all" />
+
+ <style type="text/css" media="screen">@import url(/css/style.css);</style>
+ <style type="text/css" media="screen">@import url(/css/nav.css);</style>
+
+ <script type="text/javascript"><!--//--><![CDATA[//><!--
+ startList = function() {
+ if (document.all&&document.getElementById) {
+ navRoot = document.getElementById("menu");
+ for (i=0; i<navRoot.childNodes.length; i++) {
+ node = navRoot.childNodes[i];
+ if (node.nodeName=="LI") {
+ node.onmouseover=function() {
+ this.className+=" over";
+ }
+ node.onmouseout=function() {
+ this.className=this.className.replace(" over", "");
+ }
+ }
+ }
+ }
+ }
+ window.onload=startList;
+
+ //--><!]]>
+ </script>
+ <script src="js/gallery.js" type="text/javascript" language="javascript"></script>
+ <!-- image fade: http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.htm -->
+</head>
+<body id="page-home" class="index">
+
+ <!-- Header -->
+ <div id="header">
+ <h1 class="logo">
+ <a href="/">
+ <span>The New York City Streets Renaissance</span>
+ </a>
+ </h1>
+ </div>
+ <!-- / Header -->
+
+ <hr />
+
+
+<script type="text/javascript"><!--//--><![CDATA[//><!--
+startList = function() {
+ if (document.all&&document.getElementById) {
+ navRoot = document.getElementById("menu");
+ for (i=0; i<navRoot.childNodes.length; i++) {
+ node = navRoot.childNodes[i];
+ if (node.nodeName=="LI") {
+ node.onmouseover=function() {
+ this.className+=" over";
+ }
+ node.onmouseout=function() {
+ this.className=this.className.replace(" over", "");
+ }
+ }
+ }
+ }
+}
+window.onload=startList;
+
+//--><!]]></script>
+
+ <!-- Top Level Links -->
+ <div id="toplevel">
+ <ul class="links">
+ <li id="top-home">
+ <a href="/">
+ <strong>
+ <span>Home Page</span>
+ </strong>
+ </a>
+ </li>
+ <li id="top-join">
+ <a href="/involved/join.php">
+ <strong>
+ <span>Join Us</span>
+ </strong>
+ </a>
+ </li>
+ </ul>
+ </div>
+ <!-- / Top Level Links -->
+
+ <!-- Navigation Bar -->
+ <div id="nav">
+ <ul id="menu" class="tabs">
+ <li id="nav-who" >
+ <a href="/who/">
+ <strong>
+ <span>Who We Are</span>
+ </strong>
+ </a>
+ <ul class="sub">
+ <li>
+ <a href="/who/supporters.php">
+ <span>Supporters List</span>
+ </a>
+ </li>
+ <li>
+ <a href="/who/contact.php">
+ <span>Contact Us</span>
+ </a>
+ </li>
+ </ul>
+ </li>
+ <li id="nav-nyc" >
+ <a href="/nyc/">
+ <strong>
+ <span>New York Streets</span>
+ </strong>
+ </a>
+ <ul class="sub">
+ <li>
+ <a href="/nyc/truth.php">
+ <span>The Truth About Traffic</span>
+ </a>
+ </li>
+ <li>
+ <a href="/nyc/broken.php">
+ <span>Broken Streets</span>
+ </a>
+ </li>
+ <li>
+ <a href="/nyc/building.php">
+ <span>Building on Progress</span>
+ </a>
+ </li>
+ <li>
+ <a href="/nyc/video.php">
+ <span>Video Gallery</span>
+ </a>
+ </li>
+ <li>
+ <a href="/nyc/photo.php">
+ <span>Photo Gallery</span>
+ </a>
+ </li>
+ </ul>
+ </li>
+ <li id="nav-lessons" >
+ <a href="/lessons/">
+ <strong>
+ <span>Global Lessons</span>
+ </strong>
+ </a>
+ <ul class="sub">
+ <li>
+ <a href="/lessons/chicago.php">
+ <span>Chicago</span>
+ </a>
+ </li>
+ <li>
+ <a href="/lessons/philadelphia.php">
+ <span>Philadelphia</span>
+ </a>
+ </li>
+ <li>
+ <a href="/lessons/london.php">
+ <span>London</span>
+ </a>
+ </li>
+ <li>
+ <a href="/lessons/paris.php">
+ <span>Paris</span>
+ </a>
+ </li>
+ <li>
+ <a href="/lessons/copenhagen.php">
+ <span>Copenhagen</span>
+ </a>
+ </li>
+ <li>
+ <a href="/lessons/great.php">
+ <span>What Makes a Great Street?</span>
+ </a>
+ </li>
+ <li>
+ <a href="/lessons/benefits.php">
+ <span>The Benefits of Great Streets</span>
+ </a>
+ </li>
+ <li>
+ <a href="/lessons/photo.php">
+ <span>Photo Gallery</span>
+ </a>
+ </li>
+ </ul>
+ </li>
+ <li id="nav-involved" >
+ <a href="/involved/">
+ <strong>
+ <span>Get Involved</span>
+ </strong>
+ </a>
+ <ul class="sub">
+ <li>
+ <a href="/involved/join.php">
+ <span>Join Us</span>
+ </a>
+ </li>
+ <li>
+ <a href="/involved/ways.php">
+ <span>Ways to Get Involved</span>
+ </a>
+ </li>
+ <li>
+ <a href="/involved/resources.php">
+ <span>Resources</span>
+ </a>
+ </li>
+ </ul>
+ </li>
+ <li id="nav-events" >
+ <a href="/events/">
+ <strong>
+ <span>Events</span>
+ </strong>
+ </a>
+ </li>
+ </ul>
+ <div class="clear"></div>
+ </div>
+ <!-- / Navigation Bar -->
+ <hr />
+
+ <!-- Container -->
+ <div id="container">
+
+ <!-- Body -->
+ <div id="body">
+
+ <p class="callout">
+ New York is a city best enjoyed on foot, yet we plan our streets for cars.
+ </p>
+ <p>
+ New York City's streets are the soul of its neighborhoods and the pathways to some of the world's most in-demand destinations. For generations, New Yorkers and visitors have strolled, shopped and socialized on sidewalks and street corners. Pedestrian friendly streets are the city's most fundamental assets.
+ </p>
+ <p>
+ Unfortunately, we aren't making the most of these assets. Instead, our streets are being managed almost entirely for traffic flow, with neighborhoods and business districts buckling under increasing amounts of dangerous car and truck traffic. If we continue planning our streets for cars and traffic, we will get more cars and traffic; conversely, if we start planning our cities for people and places, we will get more people and places.
+ </p>
+ <p>
+ Streets are more than just car corridors; they are valuable civic spaces and resources that need to be wisely allocated. The New York City Streets Renaissance Campaign is building the movement to re-imagine our streets as lively public places.
+ </p>
+
+ <div class="infoblock">
+ <h4>
+ Goals of the New York City Streets Renaissance
+ </h4>
+ <ul class="breakdown">
+ <li>
+ <strong>Educate</strong> New Yorkers about potential transportation policy changes that will improve quality of life across New York City
+ </li>
+ <li>
+ <strong>Promote</strong> a rebalancing of this public space away from private vehicles and toward community needs
+ </li>
+ <li>
+ <strong>Demonstrate</strong> the widespread public support for reform on these issues
+ </li>
+ <li>
+ <strong>Tap</strong> the potential of New Yorkers to re-imagine their own streets
+ </li>
+ </ul>
+ </div>
+
+ <p>
+ The choice is clear: either we choose to be defined by worsening traffic and perilous streets or we can define ourselves through great public spaces and lively streets. Through action and dialogue New Yorkers can raise expectations for their public realm. <a href="involved/join.php">Join our city-wide campaign</a> for local improvements that reflect your neighborhood's unique character.
+ </p>
+
+ </div>
+ <!-- / Body -->
+
+ <!-- Sidebar -->
+ <div id="sidebar">
+
+ <div class="barker">
+ <h3 id="home-nyc" class="join">
+ New York Streets: Video Gallery
+ </h3>
+ <ul class="video">
+ <li>
+ <a href="/nyc/video-view.php?id=1">
+ <span class="thumb"><img src="/files/videos/thumbs/introduction.jpg" alt="" /></span>
+ <strong class="title">
+ Introduction
+ </strong>
+ <span class="meta">
+ (1:00 - 2.71 MB)
+ </span>
+ <p class="caption">
+ Mark Gorton introduces the goals of the NYC Streets Renaissance project.
+ </p>
+ </a>
+ </li>
+ </ul>
+ <div class="clear"></div>
+ <p class="more">
+ <a href="/nyc/video.php">
+ More Videos »
+ </a>
+ </p>
+ </div>
+
+
+ <div class="barker">
+ <h3 id="home-lessons" class="join">
+ Global Lessons: Photo Gallery
+ </h3>
+ <ul class="video">
+ <li>
+ <a href="/lessons/photo-view.php?id=16">
+ <span class="thumb"><img src="/files/photos/thumbs/great-1.jpg" alt="" /></span>
+ <strong class="title">
+ An Engaging Street
+ </strong>
+ <p class="caption">
+ <br />
+ Queen Street in Toronto has engaging sidewalks and destinations that attract both residents and tourists.
+ </p>
+ </a>
+ </li>
+ </ul>
+ <div class="clear"></div>
+ <p class="more">
+ <a href="/lessons/photo.php">
+ More Photos »
+ </a>
+ </p>
+ </div>
+
+ <div class="barker">
+ <h3 id="home-involved" class="join">
+ StreetsBlog
+ </h3>
+ <p class="text">
+ Read the official weblog of the New York City Streets Renaissance.
+ </p>
+ <p class="more">
+ <a href="http://streetsblog.org/">
+ Visit StreetsBlog »
+ </a>
+ </p>
+ </div>
+
+ <div class="barker">
+ <h3 id="home-involved" class="join">
+ Get Involved
+ </h3>
+ <p class="text">
+ Stay informed and send a strong message that you support a better quality of streets by signing up for our mailing list.
+ </p>
+ <p class="more">
+ <a href="/involved/join.php">
+ Join Us »
+ </a>
+ </p>
+ </div>
+
+
+ </div>
+ <!-- / Sidebar -->
+
+ <div class="clear"></div>
+
+ </div>
+ <!-- / Container -->
+
+ <hr />
+
+ <!-- Footer -->
+ <div id="footer">
+ <p class="links">
+ [
+ <a href="/">
+ <span>Home</span>
+ </a>
+ |
+ <a href="/who/">
+ <span>Who We Are</span>
+ </a>
+ |
+ <a href="/nyc/">
+ <span>New York Lessons</span>
+ </a>
+ |
+ <a href="/lessons/">
+ <span>Global Lessons</span>
+ </a>
+ |
+ <a href="/involved/">
+ <span>Get Involved</span>
+ </a>
+ |
+ <a href="/events/">
+ <span>Events</span>
+ </a>
+ |
+ <a href="/involved/join.php">
+ <span>Join Us</span>
+ </a>
+ ]
+ </p>
+ <p class="cc">
+ <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/">
+ <img alt="Creative Commons License" border="0" src="/img/logos/cc.png" class="logo" /><br />
+ These works are licensed under a Creative Commons License
+ </a>
+ </p>
+ <!--
+ <rdf:RDF xmlns="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+ <Work rdf:about="">
+ <license rdf:resource="http://creativecommons.org/licenses/by-nc-nd/2.5/" />
+ <dc:type rdf:resource="http://purl.org/dc/dcmitype/Text" />
+ </Work>
+ <License rdf:about="http://creativecommons.org/licenses/by-nc-nd/2.5/">
+ <permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
+ <permits rdf:resource="http://web.resource.org/cc/Distribution"/>
+ <requires rdf:resource="http://web.resource.org/cc/Notice"/>
+ <requires rdf:resource="http://web.resource.org/cc/Attribution"/>
+ <prohibits rdf:resource="http://web.resource.org/cc/CommercialUse"/>
+ </License>
+ </rdf:RDF>
+ -->
+ </div>
+ <!-- / Footer -->
+</body>
+</html>
Added: z3/deliverance/branches/packaged/deliverance/test_speed.py
==============================================================================
--- (empty file)
+++ z3/deliverance/branches/packaged/deliverance/test_speed.py Tue Oct 10 22:06:00 2006
@@ -0,0 +1,73 @@
+import sys
+from lxml import etree
+from htmlserialize import tostring
+import urllib
+from interpreter import Renderer as PythonRenderer
+from xslt import Renderer as XSLTRenderer
+from optparse import OptionParser
+import re
+import os
+from time import time
+
+"""
+Tests the relative speed of the Python and XSLT renderers
+
+"""
+
+
+DEFAULT_BASE_URL = "http://www.example.com"
+
+
+def grab_url(url):
+ f = open(url)
+ data = f.read()
+ f.close()
+ return data
+
+def do_transform(renderer_type, theme_url, base_url, rules_url, content_url):
+ rules = etree.XML(grab_url(rules_url))
+ theme = etree.HTML(grab_url(theme_url))
+ content = etree.HTML(grab_url(content_url))
+
+ def reference_resolver(href, parse, encoding=None):
+ if not href.startswith('/'):
+ href = os.path.join(os.path.dirname(rules_url),href)
+ text = grab_url(href)
+ if parse == "xml":
+ return etree.XML(text)
+ elif encoding:
+ return text.decode(encoding)
+
+ start = time()
+ iters = 1000
+ for i in range(iters):
+ renderer = None
+ if renderer_type == 'xslt':
+ renderer = XSLTRenderer(theme,base_url,rules,reference_resolver)
+ elif renderer_type == 'py':
+ renderer = PythonRenderer(theme,base_url,rules,reference_resolver)
+ else:
+ print "Unknown renderer type '" + renderer_type + "'"
+ return etree.Element("error")
+ renderer.render(content)
+
+ print "Renderer: " + renderer_type
+ print "*** time:", time() - start , " for " , iters, " iterations ***\n"
+
+ return
+
+
+def parse_blend_file(filename):
+ b = etree.XML(open(filename).read())
+ return b.get('theme'),b.get('baseurl'),b.get('rules')
+
+
+def die(message,parser):
+ print message
+ parser.print_usage()
+ sys.exit(0)
+
+if __name__ == '__main__':
+ do_transform('xslt','test-data/nycsr/nycsr_speed.html','http://www.nycsr.org','test-data/nycsr/nycsr.xml','test-data/nycsr/openplans.html')
+ do_transform('py','test-data/nycsr/nycsr_speed.html','http://www.nycsr.org','test-data/nycsr/nycsr.xml','test-data/nycsr/openplans.html')
+
More information about the z3-checkins
mailing list