 |
Changeset 3324
- Timestamp:
- 03/02/08 16:34:05
(9 months ago)
- Author:
- kris
- Message:
replaced import(file) with File(name).read;
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r3236 |
r3324 |
|
| 8 | 8 | *******************************************************************************/ |
|---|
| 9 | 9 | |
|---|
| | 10 | import tango.io.File; |
|---|
| 10 | 11 | import tango.io.Stdout; |
|---|
| 11 | 12 | import tango.time.StopWatch; |
|---|
| … | … | |
| 21 | 22 | |
|---|
| 22 | 23 | auto doc = new Document!(char); |
|---|
| 23 | | auto content = import ("hamlet.xml"); |
|---|
| | 24 | auto content = cast (char[]) File("hamlet.xml").read; |
|---|
| 24 | 25 | |
|---|
| 25 | 26 | elapsed.start; |
|---|
| r3236 |
r3324 |
|
| | 1 | import tango.io.File; |
|---|
| 1 | 2 | import tango.io.Stdout; |
|---|
| 2 | 3 | import tango.time.StopWatch; |
|---|
| 3 | | |
|---|
| 4 | 4 | import tango.text.xml.PullParser; |
|---|
| 5 | 5 | |
|---|
| 6 | | void benchmark (int iterations, char[] filename) |
|---|
| | 6 | void benchmark (int iterations) |
|---|
| 7 | 7 | { |
|---|
| 8 | 8 | StopWatch elapsed; |
|---|
| 9 | 9 | |
|---|
| 10 | | auto content = import ("hamlet.xml"); |
|---|
| | 10 | auto content = cast (char[]) File("hamlet.xml").read; |
|---|
| 11 | 11 | auto parser = new PullParser!(char) (content); |
|---|
| 12 | 12 | |
|---|
| | 13 | uint j; |
|---|
| 13 | 14 | elapsed.start; |
|---|
| 14 | 15 | for (auto i=0; ++i < iterations;) |
|---|
| 15 | 16 | { |
|---|
| 16 | | while (parser.next) {} |
|---|
| | 17 | while (parser.next) {++j;} |
|---|
| 17 | 18 | parser.reset; |
|---|
| 18 | 19 | } |
|---|
| 19 | | Stdout.formatln ("{} MB/s", (content.length * iterations) / (elapsed.stop * (1024 * 1024))); |
|---|
| | 20 | Stdout.formatln ("{} MB/s, {} tokens", (content.length * iterations) / (elapsed.stop * (1024 * 1024)), j); |
|---|
| 20 | 21 | } |
|---|
| 21 | 22 | |
|---|
| | 23 | |
|---|
| 22 | 24 | void main() |
|---|
| 23 | | { |
|---|
| | 25 | { |
|---|
| | 26 | // uncomment me, and try again ... |
|---|
| | 27 | //char[] s = null; |
|---|
| 24 | 28 | for (int i = 10; --i;) |
|---|
| 25 | | benchmark (2000, "hamlet.xml"); |
|---|
| | 29 | benchmark (2000); |
|---|
| 26 | 30 | } |
|---|
| | 31 | |
|---|
| r3243 |
r3324 |
|
| 1 | 1 | module xmlsax; |
|---|
| 2 | 2 | |
|---|
| | 3 | import tango.io.File; |
|---|
| 3 | 4 | import tango.io.Stdout; |
|---|
| 4 | 5 | import tango.time.StopWatch; |
|---|
| 5 | | |
|---|
| 6 | 6 | import tango.text.xml.SaxParser; |
|---|
| 7 | 7 | |
|---|
| 8 | | void benchmark (int iterations, SaxParser!(char) parser, char[] content) |
|---|
| | 8 | void main() |
|---|
| 9 | 9 | { |
|---|
| 10 | | StopWatch elapsed; |
|---|
| 11 | | elapsed.start; |
|---|
| 12 | | |
|---|
| 13 | | for (auto i=0; ++i < iterations;) |
|---|
| 14 | | { |
|---|
| 15 | | parser.parse; |
|---|
| 16 | | parser.reset; |
|---|
| 17 | | } |
|---|
| 18 | | |
|---|
| 19 | | Stdout.formatln ("{} MB/s", (content.length * iterations) / (elapsed.stop * (1024 * 1024))); |
|---|
| | 10 | for (int i = 10; --i;) |
|---|
| | 11 | { |
|---|
| | 12 | auto parser = new SaxParser!(char); |
|---|
| | 13 | auto handler = new LengthHandler!(char); |
|---|
| | 14 | parser.setSaxHandler(handler); |
|---|
| | 15 | benchmark (2000, parser); |
|---|
| | 16 | } |
|---|
| 20 | 17 | } |
|---|
| 21 | 18 | |
|---|
| 22 | 19 | |
|---|
| 23 | | void main() |
|---|
| | 20 | void benchmark (int iterations, SaxParser!(char) parser) |
|---|
| 24 | 21 | { |
|---|
| 25 | | auto content = import ("hamlet.xml"); |
|---|
| 26 | | auto parser = new SaxParser!(char); |
|---|
| 27 | | //auto handler = new EventsHandler!(char); |
|---|
| 28 | | //auto handler = new SaxHandler!(char); |
|---|
| 29 | | auto handler = new LengthHandler!(char); |
|---|
| 30 | | parser.setSaxHandler(handler); |
|---|
| | 22 | StopWatch elapsed; |
|---|
| | 23 | |
|---|
| | 24 | auto content = cast(char[]) File("hamlet.xml").read; |
|---|
| 31 | 25 | parser.setContent(content); |
|---|
| 32 | 26 | |
|---|
| 33 | | for (int i = 10; --i;) |
|---|
| 34 | | benchmark (2000, parser, content); |
|---|
| | 27 | elapsed.start; |
|---|
| | 28 | for (auto i=0; ++i < iterations;) |
|---|
| | 29 | { |
|---|
| | 30 | parser.parse; |
|---|
| | 31 | parser.reset; |
|---|
| | 32 | } |
|---|
| | 33 | Stdout.formatln ("{} MB/s", (content.length * iterations) / (elapsed.stop * (1024 * 1024))); |
|---|
| 35 | 34 | } |
|---|
| 36 | 35 | |
|---|
Download in other formats:
|
 |
 |
|
 |
Copyright © 2006-2008 Tango. All Rights Reserved. | Page Width:
Static or
Dynamic