[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qexo-general] Speed of execution
From: |
Eric Safern |
Subject: |
[Qexo-general] Speed of execution |
Date: |
Tue, 14 Jan 2003 17:07:15 -0800 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2a) Gecko/20020910 |
Hi,
I'm having some interesting performance issues I want to discuss with
the list.
My initial app is a simple implementation of fortune(6).
http://www.die.net/doc/linux/man/man6/fortune.6.html
With the full linux fortune data as its input (> 100,000 lines), the
servlet takes 4 - 7 seconds on my test box, which strikes me as too long
for an impatient web surfer. On a far smaller subset of data (4,000
lines), response time comes in at 1 - 2 seconds, which is still longer
than I'd like.
My algorithm may be part of the problem - I grab the entire
block of fortunes in a particular type, then I choose a random number
between 1 and the number of fortunes of that type. Finally, I zoom in
on that particular fortune, which I display.
Of course, this means I need to load a large block of fortunes
I don't really care about. I did this because I need to know the
number of fortunes in the block in order to randomly choose one from
that range. Is there a better way? Clearly, hard-wiring the type
counts is not the answer. I could have the info embedded in the xml,
but that would a) be tricky to code and b) be a hassle for those adding
new fortunes to the data.
Any suggestions?
Here's some code:
$cookies :=
document("/var/www/html/fortunes.xml")/fortunes/address@hidden/cookie,
$min := 1,
$max := count($cookies),
$rnd := Rand($min,$max),
$ck := $cookies [$rnd]
return
RenderPage ($ck)
Are there any implementation level things I could do to speed up
my execution? Different compilation methods / flags, etc. etc.?
If my DTD is relevant, here it is:
<!ELEMENT fortunes (list+)>
<!ELEMENT list (cookie+)>
<!ELEMENT cookie (text, (author?))>
<!ELEMENT text (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ATTLIST list type NMTOKEN "unknown">
<!ATTLIST cookie src NMTOKEN "unknown" id ID #REQUIRED>
and here's a short sample of the data for clarity:
<?xml version="1.0" encoding="US-ASCII" standalone="no"?>
<!DOCTYPE fortunes SYSTEM "http://linux.timebytes.com/dtds/fortunes.dtd">
<fortunes xml:lang="en-US">>
<list type="linuxcookie">
<cookie src="linuxcookie" id="linuxcookie-1">
<text>
A Linux machine! because a 486 is a terrible thing to
waste!
</text>
<author>
address@hidden, Joe Sloan
</author>
</cookie>
<cookie src="linuxcookie" id="linuxcookie-6">
<text>
"All language designers are arrogant. Goes with
the territory..."
</text>
<author>
Larry Wall
</author>
</cookie>
</list>
</fortunes>
- [Qexo-general] Speed of execution,
Eric Safern <=