473,395 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

output large arrays to html

Hello,

I'm looking for ways to 'echo' a single large associative array
repeatedly w/ as little overhead as possible.

I'm developing a simple subscription form, two steps, one page. In
step 1 the subscriber selects their country from a drop down menu
whose name and value pairs are based on ISO standards. In step 2 user
has the option to return to 1 and edit.

I mined the ascii data from the ISO Web page src, edited it, and
dumped it to MySQL, intending to dynamically generate my menu. But now
I'm concerned that every time a subscriber wishes to edit input, they
will experience a lag in the middle of the page while some 200+ select
options are echo'ed to the screen.

I've attempted to solve that concern using the following technique in
a global scope:

if (!isset($huge_assoc_array))
$huge_assoc_array = mine_from_db();

Does this accomplish the intended result, reducing print-to-screen
time on requests beyond the first? If subscriber clicks input button
'edit,' returning to step one, will mine_from_db() execute again?

Not sure of the answer, I've considered two alternative techniqes:
a) $_SESSION['huge_assoc_array'] = mine_from_db(); and
b) using Curl or similar to mine, on each request, from iso.org.

If you've dealt with this I would love to hear your success and
failure stories.

Thanks for any advice,
Brian Huntington
Jul 17 '05 #1
4 2344
Hi Brian!
On 20 Nov 2003 19:42:13 -0800, bh*********@agu.org (Brian Huntington)
wrote:
Hello,
(...)
I mined the ascii data from the ISO Web page src, edited it, and
dumped it to MySQL, intending to dynamically generate my menu. But now
I'm concerned that every time a subscriber wishes to edit input, they
will experience a lag in the middle of the page while some 200+ select
options are echo'ed to the screen.
Have you measured how long it takes? Have a look at microtime(). I
think it does take barely any time in relation to transferring it to
the client browser.

I've attempted to solve that concern using the following technique in
a global scope:

if (!isset($huge_assoc_array))
$huge_assoc_array = mine_from_db();

Does this accomplish the intended result, reducing print-to-screen
time on requests beyond the first? If subscriber clicks input button
'edit,' returning to step one, will mine_from_db() execute again?
On every reload.

Not sure of the answer, I've considered two alternative techniqes:
a) $_SESSION['huge_assoc_array'] = mine_from_db();
less overhead with the db, but takes disk space from all users on the
server. b) using Curl or similar to mine, on each request, from iso.org.
Thats definitely slower than fetching it (cached!) from a db on teh
server.

If you've dealt with this I would love to hear your success and
failure stories.


I have a page with about 15 selects with around 2000 options and it
takes low spec machines (32MB) about 2 seconds to render the page. All
come from the db and take around 1 second to fetch. The server side
time is relatively small in relation to the time for transferring it
to the browser and rendering it.

You only have a problem, if a large amount of your users has the
select boxes on their screen, as it will then eat server resources.
But I suppose they will click links most of the time rather than
filling forms (which takes human interaction == time)

HTH, Jochen
--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 17 '05 #2
Brian Huntington:
Hello,

I'm looking for ways to 'echo' a single large associative array
repeatedly w/ as little overhead as possible.

I'm developing a simple subscription form, two steps, one page. In
step 1 the subscriber selects their country from a drop down menu
whose name and value pairs are based on ISO standards. In step 2 user
has the option to return to 1 and edit.

I mined the ascii data from the ISO Web page src, edited it, and
dumped it to MySQL, intending to dynamically generate my menu. But now
I'm concerned that every time a subscriber wishes to edit input, they
will experience a lag in the middle of the page while some 200+ select
options are echo'ed to the screen.


I keep saying this a lot ... Oh well: "Premature optimization is the root of
all evil." - Donald Knuth.

But why you are storing the countries in a MySQL database is beyond me, just
put them directly in an array.

André Næss
Jul 17 '05 #3
Jochen Daum wrote:
Hi Brian!
On 20 Nov 2003 19:42:13 -0800, bh*********@agu.org (Brian Huntington)
wrote:
Hello,

(...)

I mined the ascii data from the ISO Web page src, edited it, and
dumped it to MySQL, intending to dynamically generate my menu. But now
I'm concerned that every time a subscriber wishes to edit input, they
will experience a lag in the middle of the page while some 200+ select
options are echo'ed to the screen.


Have you measured how long it takes? Have a look at microtime(). I
think it does take barely any time in relation to transferring it to
the client browser.

I've attempted to solve that concern using the following technique in
a global scope:

if (!isset($huge_assoc_array))
$huge_assoc_array = mine_from_db();

Does this accomplish the intended result, reducing print-to-screen
time on requests beyond the first? If subscriber clicks input button
'edit,' returning to step one, will mine_from_db() execute again?


On every reload.

Not sure of the answer, I've considered two alternative techniqes:
a) $_SESSION['huge_assoc_array'] = mine_from_db();


less overhead with the db, but takes disk space from all users on the
server.
b) using Curl or similar to mine, on each request, from iso.org.


Thats definitely slower than fetching it (cached!) from a db on teh
server.

If you've dealt with this I would love to hear your success and
failure stories.


I have a page with about 15 selects with around 2000 options and it
takes low spec machines (32MB) about 2 seconds to render the page. All
come from the db and take around 1 second to fetch. The server side
time is relatively small in relation to the time for transferring it
to the browser and rendering it.

You only have a problem, if a large amount of your users has the
select boxes on their screen, as it will then eat server resources.
But I suppose they will click links most of the time rather than
filling forms (which takes human interaction == time)

HTH, Jochen


Ya, I just made a script that prints 4000+ lines from SQL to the browser,
and it takes no time at all. (I'm connecting to localhost, so download
times are instantaneous. I notice no lag at all)
Jul 17 '05 #4
Jochen Daum <jo*********@cans.co.nz> wrote in message news:<mb********************************@4ax.com>. ..
Hi Brian!
On 20 Nov 2003 19:42:13 -0800, bh*********@agu.org (Brian Huntington)
wrote:
Hello,

(...) etc..
Have you measured how long it takes? Have a look at microtime(). I
think it does take barely any time in relation to transferring it to
the client browser.


Thanks for the suggestions Jochen. On your advice I timed the block of
code that mines and prints country option pairs. Every load produced
results less than two tenths of a second. Several reloads were in
hundreths of a second. I'm very pleased with the results, as they are
much better than I expected. Thank you for pointing me in the right
direction so that I could debunk my suspicions regarding over-long
print-to-screen times.

Brian H.
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Pjotr Wedersteers | last post by:
Hi, When I include a script in my html I don't get any output back in the calling page. The script is on a remote location for the html page. Example given: myscript.php: <?PHP echo...
1
by: jose luis fernandez diaz | last post by:
Hi, In the chapter 4 'Collections and Records' of the 'PL/SQL User's Guide and Reference Release 8.1.6' book there is the next paragrap: "For example, PL/SQL supports implicit (automatic)...
2
by: matthew.weiner | last post by:
I have a bunch of SPs that all rely on a UDF that parses a comma delimitted list of numbers into a table. Everything was working fine, but now my application is growing and I'm starting to...
19
by: Hal Styli | last post by:
Hello, Can someone please help. I need to use a large array and I'm not sure when one should use (A) and when one should use (B) below:- #define MAX 10000000 (A) int x;
0
by: Alastair Alexander | last post by:
Hi ... I'm using pythoncom to create a python COM server application that needs to be able to return large arrays to COM client apps. For example, I need to be able to return an array to Excel that...
10
by: Peter Duniho | last post by:
This is kind of a question about C# and kind of one about the framework. Hopefully, there's an answer in there somewhere. :) I'm curious about the status of 32-bit vs 64-bit in C# and the...
17
by: Stubert | last post by:
I have a training module db that stores information about employees and what training they have carried our or need to carry out. One table in this database stores what training needs to be carried...
3
by: John | last post by:
I have two large arrays. Is there a rapid method to comaprs the two arrays and creat a third array of onlt thos items that the are in the first array but not the second array. I do it manually...
3
by: hamishd | last post by:
What is the best way to store large arrays of numbers (eg, 4-byte integers)? Say I want to store an array of 1billion 4-byte integers.. If my computer has 4gB memory, then is this possible? ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.