Commit 45c23a65 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2003-04-03 17:17:41 by cvscast] Empty log message

Original author: cvscast
Date: 2003-04-03 17:17:41+00:00
parent 0ff53e91
......@@ -25,19 +25,28 @@ This page briefly presents preliminary benchmarks on the CDuce prototype.
<box title="Methodology" link="meth">
<p>
<b>This page is under construction.</b>
The benchmarks were performed on a Linux box, Athlon 750, 128 Mb RAM.
The results are given in seconds. They were measured with
the Unix <tt>time</tt> command. The user time is reported unless
otherwise specified.
</p>
<p>
The benchmarks were performed on a Linux box, Athlon 750, 128 Mb RAM.
These are only <b>preliminary benchmarks</b>, and results
should be taken with much care.
</p>
</box>
<box title="CDuce alone" link="cduce">
</box>
<box title="CDuce vs. XDuce" link="xduce">
<section title="Addrbook">
<p>
This example was taken from XDuce distribution.
The transformation is simple;
the example is intended to evaluate run-time efficiency.
</p>
<p>
<a href="bench/addrbook.cd">CDuce source</a> -
<a href="bench/addrbook.q">XDuce source</a> -
......@@ -63,21 +72,75 @@ The benchmarks were performed on a Linux box, Athlon 750, 128 Mb RAM.
</table>
<p>
The * corresponds to checks stopped after ten minutes.
</p>
</section>
<section title="Html2latex">
<p>
This example was taken from XDuce distribution and simplified
(removed support for tables). The transformation is more complex;
the example is intended to evaluate type-checking time.
</p>
<p>
<a href="bench/html2latex.cd">CDuce source</a> -
<a href="bench/xhtml-trans.cd">CDuce source (XHTML Transitional DTD)</a> -
<a href="bench/html2latex.q">XDuce source</a> -
<a href="bench/tst_html2latex.xml">Sample input XML file</a>.
</p>
<table border="1">
<tr> <td>Html2latex</td>
<th>XDuce 0.2.4</th>
<th>XDuce 0.2.4 + patopt</th>
<th>XDuce 0.4.0 + patopt</th>
<th>CDuce</th> </tr>
<tr align="right"> <th>Type-checking</th>
<td>1.5</td> <td>21.4</td> <td>9.5</td> <td>0.4</td> </tr>
<tr align="right"> <th>Total</th>
<td>2.3</td> <td>26.5</td> <td>10.0</td> <td>0.8</td> </tr>
</table>
</section>
</box>
<box title="CDuce vs. XSLT" link="xslt">
<p>
We also performed benchmarks between CDuce and a fast XSLT processor (the
{\tt xsltproc} program from <a href="http://xmlsoft.org/XSLT/">
<tt>xsltproc</tt> program from <a href="http://xmlsoft.org/XSLT/">
Gnome libxslt library</a>).
</p>
<p>
<a href="bench/addrbook.cd">CDuce source</a> -
<a href="bench/addrbook.xslt1.xml">XSLT source</a> -
<a href="bench/addrbook.xslt2.xml">XSLT source (another version)</a> -
<a href="bench/addrbook.ml">OCaml file</a> (to generate random documents).
The example is intended to evaluate run-time efficiency. Even though
the transformation is quite complex, type-checking time for CDuce
is negligible. A few remarks:
</p>
<ul>
<li>type-based optimization
brings almost no gain (only tag checks can be avoided);</li>
<li>the CDuce program must validate its input document (the XSLT
stylesheet can operate on any document);</li>
<li>the XSLT processor is written in C; the CDuce interpreter
is written in Objective Caml.</li>
</ul>
<p>
Taking these remarks into account, the results below are more than
encouraging.
</p>
<p>
<a href="bench/sort.cd">CDuce source</a> -
<a href="bench/sort.xslt1.xml">XSLT source</a> -
<a href="bench/sort.xslt2.xml">XSLT source (another version)</a> -
<a href="bench/sort.ml">OCaml file</a> (to generate random documents).
</p>
......@@ -88,14 +151,30 @@ Gnome libxslt library</a>).
<th>CDuce</th> </tr>
<tr align="right"> <th>5 Mb</th>
<td>8.90 / 9.05</td> <td>8.05 / 8.26</td> <td>5.30 / 5.40</td> </tr>
<td>8.90</td> <td>8.05</td> <td>5.30</td> </tr>
<tr align="right"> <th>27 Mb</th>
<td>47.10 / 320.80</td> <td>68.40 / 324.50</td> <td>33.85 / 83.65</td> </tr>
<td>47.10</td> <td>68.40</td> <td>33.85</td> </tr>
</table>
The two numbers correspond respectively to total CPU user time
(parsing + transformation), and total wall-clock time (parsing + transformation
+ system time).
<p>
The table above displays CPU user time (parsing + transformation) .
The table below, instead, displays total wall-clock time
(including system time). The results indicate that CDuce
behave much better when the XML document
does'nt fit in memory (and swapping occurs).
</p>
<table border="1">
<tr> <td>sort</td>
<th>XSLT (1)</th>
<th>XSLT (2)</th>
<th>CDuce</th> </tr>
<tr align="right"> <th>5 Mb</th>
<td>9.05</td> <td>8.26</td> <td>5.40</td> </tr>
<tr align="right"> <th>27 Mb</th>
<td>320.80</td> <td>324.50</td> <td>83.65</td> </tr>
</table>
</box>
......
(* This CDuce script produces CDuce web site. *)
include "xhtml-strict.cd";; (* XHTML 1 Strict DTD *)
include "xhtml-categ.cd";; (* Categories (Inline, ...) from this DTD *)
......@@ -40,7 +43,7 @@ type Content =
type InlineText =
Char
| <(`b|`i) {||}>[InlineText*]
| <(`b|`i|`tt) {||}>[InlineText*]
| <duce>[InlineText*]
| Xa
| Ximg | Xbr ;;
......@@ -55,21 +58,17 @@ let fun authors ([Author+] -> String)
| [ <author>a; rem ] -> a @ ", " @ authors rem;;
let fun text (t : [InlineText*]) : Inlines =
map t with
<duce>x -> <b>[ <tt>(text x) ]
| <b>x -> <b>(text x)
| <i>x -> <i>(text x)
| z -> z;;
map t with
| <duce>x -> <b>[ <tt>(text x) ]
| <(tag & (`b|`i|`tt))>x -> <(tag)>(text x)
| z -> z;;
let fun content (t : Content) : Flow =
transform t with
| <section title=title>c -> [ <h4>title !(content c) ]
| <section title=title>c ->
[ <h4>title !(content c) ]
| <paper (r)>[ <title>tit aut::Author* <comment>com <abstract>ab ] ->
[
(match r with
| { file = f } -> <a href=f>tit
| _ -> <b>tit
) '. '
[ (match r with { file = f } -> <a href=f>tit | _ -> <b>tit) '. '
!(authors aut) '. '
!(text com)
<div class="abstract">[ 'Abstract:' !(content ab) ]
......@@ -77,19 +76,14 @@ let fun content (t : Content) : Flow =
| <slides file=f>[ <title>tit aut::Author* <comment>com ] ->
[ <a href=f>tit '. ' !(authors aut) '. ' !(text com) ]
| <include-verbatim file=f>[] ->
let code = load_file f in
let code = transform code with
(* | c & ('a'--'z') -> [ <b>[c] ] *)
(* | ' ' -> "\160" *)
| c -> [c] in
[
<div class="code">[ <pre>code ]
]
| <link url=url; title=title>com -> [ <a href=url>title '. ' !(text com) ]
| <ul>lis -> [ <ul>(map lis with <li>x -> <li>(content x)) ]
| Xtable & x -> [ x ]
[ <div class="code">[ <pre>(load_file f) ] ]
| <link url=url; title=title>com ->
[ <a href=url>title '. ' !(text com) ]
| <ul>lis ->
[ <ul>(map lis with <li>x -> <li>(content x)) ]
| Xtable & x ->
[ x ]
| <p>x -> [ <p>(text x) ]
| <ul>x -> [ <ul>(text x) ]
| x -> text [ x ];;
let fun main2html (Box -> Flow)
......@@ -102,6 +96,11 @@ let fun main2html (Box -> Flow)
| <meta>c -> [ <div class="meta">(content c) ];;
(* Ugly hack to introduce PHP code ...
The idea is to produce first an XML document with a distinguished element.
The function patch_css search for the textual representation of this
element and replace it with the PHP code. *)
let php_css : String =
[' <?php
$browser = getenv("HTTP_USER_AGENT");
......@@ -139,7 +138,7 @@ let fun page2html (Page -> Xhtml)
<head>[
<title>title
<meta content="text/html; charset=iso-8859-1"; http-equiv="Content-Type">[]
<meta content="css">[]
<meta content="css">[] (* Placeholder for PHP code *)
]
<body>[
<div class="title">[ <h1>(text banner) ]
......@@ -149,18 +148,19 @@ let fun page2html (Page -> Xhtml)
];;
type P = (String,<title>String);;
let fun make_plan (l : [ P+ ]) : Page =
<page>[ <title>"CDuce site"
<banner>"CDuce site"
<navig>[ <box>[ <a href="/">"Home" ] ]
<main>[
<box title="Pages"; link="pages">[
<ul>(map l with (file,<title>t) -> <li>[<a href=file>t]) ]
<meta>[
'This page was automatically generated by a CDuce program.'
]
]
];;
<page>[
<title>"CDuce site"
<banner>"CDuce site"
<navig>[ <box>[ <a href="/">"Home" ] ]
<main>[
<box title="Pages"; link="pages">[
<ul>(map l with (file,<title>t) -> <li>[<a href=file>t])
]
<meta>[ 'This page was automatically generated by a CDuce program.' ]
]
];;
let fun do_page((Page,String) -> [])
(page,outf) ->
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment