Ask Question Forum:
Model Library:2025-02-08 Updated:A.I. model is online for auto reply question page
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by duncanb7
at 2024-04-17 23:51:43
Point:500 Replies:10 POST_ID:828479USER_ID:11059
Topic:
Hypertext Markup Language (HTML);JavaScript;PHP Scripting Language
I get a php code for making a table of 300*16 that is an easy one, please help to review the php code
Why it is slower than the code I also attached from Javascript.
Is it my php code the each cell 's string concatenation is issue for slower speed or Actually slower speed is
due to my shared-domain server might be slower than my PC so javascript is client lanaguage will be better speed
running on user side ?
In php, I used file open to open the data of csv file, In javascript, I am xmlhttp.request to get the data of csv file
What is main different in speed ?
Please advise
Duncan
Why it is slower than the code I also attached from Javascript.
Is it my php code the each cell 's string concatenation is issue for slower speed or Actually slower speed is
due to my shared-domain server might be slower than my PC so javascript is client lanaguage will be better speed
running on user side ?
In php, I used file open to open the data of csv file, In javascript, I am xmlhttp.request to get the data of csv file
What is main different in speed ?
Please advise
Duncan
Using javascript to form a table of 300*16 cells==================================================!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html ><head><script type="text/javascript" language="javascript"><!---function inner2(data){ var y=0; var k=123;var dataRows = data.split( "" ); var string = new Array(); string.push('<table>'); columnwidth(string); string.push('<tbody>');try { for (var i=0;i<300;i++) { var dataCells = dataRows[i].split(","); string.push('<tr>'); for (var j=0;j<dataCells.length; j++) { y='<td>'+ dataCells[j] + '</td>'; string.push(y); } string.push('</tr>'); } }catch(err) {} string.push('</tbody></table>'); var writestring = string.join(''); document.getElementById('writeroot').innerHTML = writestring;function getData( url){var xmlhttp;if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); }else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if ( xmlhttp.readyState == 4 ) { // alert("Waiting render"); inner2( xmlhttp.responseText );//alert("render finsh"); } } xmlhttp.open( "GET", url, true ); xmlhttp.send( null );}function test () { getData("http://www.mydomian.com/example.csv" );}// --></script></head><body onload="test();" style="background-color:#e0ffff"><div id="writeroot"></div></body></html> 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:41:42:43:44:45:46:47:48:49:50:51:52:53:54:55:56:57:58:59:60:61:62:63:64:65:66:67:68:69:70:71:72:73:
Using php code to make a table 300&"16 cells=============================================<"!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">"<"html>"<"head>"<"title>"Testing<"/title>"<"/head>"<"body ondragstart="return false" onselectstart="return false">"<"table>"<"tbody>"<"?php$file_handle = fopen("http://www.mydomain.com/example.csv", "r");"$store="";"while (!feof($file_handle) ) {$line_of_text = fgetcsv($file_handle, 1024);" $store = $store . "<"tr>"<"td>"".$line_of_text[0]."<"/td>"<"td>"". $line_of_text[1]."<"/td>"<"td>"". $line_of_text[2]."<"/td>"<"td>"" .$line_of_text[3]."<"/td>"<"td>"". $line_of_text[4] ."<"/td>"<"td>"". $line_of_text[5]."<"/td>"<"td>"" .$line_of_text[6] ."<"/td>"<"td>"".$line_of_text[7]."<"/td>"<"td>"". $line_of_text[8]."<"/td>"<"td>"". $line_of_text[9]."<"/td>"<"td>"". $line_of_text[10]."<"/td>"<"td>"" .$line_of_text[11]."<"/td>"<"td>"". $line_of_text[12] ."<"/td>"<"td>"". $line_of_text[13]."<"/td>"<"td>"". $line_of_text[14]."<"/td>"<"td>"" .$line_of_text[15]."<"/td>"<"tr>"";"}fclose($file_handle);"echo $store;"?>"<"/tbody>"<"/table>"<"/body>"<"/html>" 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:
Author: duncanb7 replied at 2024-04-30 13:35:47
Thanks for all of your reply
It is sovled when I using
curl from php
It is sovled when I using
curl from php
Assisted Solution
Expert: Ray Paseur replied at 2024-04-21 08:00:26
100 points EXCELLENT
ionCube and Suhosin might contribute to making a site slow.
http://www.ioncube.com/
http://www.hardened-php.net/suhosin/
http://www.ioncube.com/
http://www.hardened-php.net/suhosin/
Author: duncanb7 replied at 2024-04-18 06:22:32
THanks for all reply , and I try to see my php version and get the final output as follows , ,
and Whether I 've already installed op-code cache such as Zend Optimizer ?
If yes, I think I have nothing to do to improve to do beside Zend or APC optimizer, Is it right ?
#php -version
PHP 5.2.16 (cli) (built: Jan 27 2011 21:18:47)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
with the ionCube PHP Loader v3.3.20, Copyright (c) 2002-2010, by ionCube Ltd., and
with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies
with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
and Whether I 've already installed op-code cache such as Zend Optimizer ?
If yes, I think I have nothing to do to improve to do beside Zend or APC optimizer, Is it right ?
#php -version
PHP 5.2.16 (cli) (built: Jan 27 2011 21:18:47)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
with the ionCube PHP Loader v3.3.20, Copyright (c) 2002-2010, by ionCube Ltd., and
with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies
with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
Assisted Solution
Expert: Ray Paseur replied at 2024-04-18 02:25:32
100 points EXCELLENT
The processor speed of the server or the client is almost certainly irrelevant to this question. You are doing very little processing but you are moving a lot of data (in a relative meaning of "a lot"). So the speed of your internet connection is probably the defining characteristic of the different speeds you might observe. If the question is, "How do I speed up my PHP script?" the first thing you want to know is what might be making it slow. Line 16 says this:
$line_of_text = fgetcsv($file_handle, 1024);
Since you gave us a bogus URL for $file_handle we cannot tell you what the speed of the remote web service might be. Try to figure that out and see how much time you are spending reading the external data.
Consider using output buffering in PHP. Consider an op-code cache. Measure the amount of memory available to your scripts and see if 128M is enough. Determine the connection speed at the server and at the client. Are these the same or is one faster than the other? With a few details like this you will be able to see what is defining the performance of each different version of your application.
Best of luck with it, ~Ray
$line_of_text = fgetcsv($file_handle, 1024);
Since you gave us a bogus URL for $file_handle we cannot tell you what the speed of the remote web service might be. Try to figure that out and see how much time you are spending reading the external data.
Consider using output buffering in PHP. Consider an op-code cache. Measure the amount of memory available to your scripts and see if 128M is enough. Determine the connection speed at the server and at the client. Are these the same or is one faster than the other? With a few details like this you will be able to see what is defining the performance of each different version of your application.
Best of luck with it, ~Ray
Author: duncanb7 replied at 2024-04-18 00:31:11
Because I just have 128M memory in server and
If running javascript in my PC , I get 2G RAM memory that
is main different to the table speed
ONe more question, generally on PC, what is cache memory size ? is it 64M in 2G memory of PC ?
If running javascript in my PC , I get 2G RAM memory that
is main different to the table speed
ONe more question, generally on PC, what is cache memory size ? is it 64M in 2G memory of PC ?
Assisted Solution
Expert: roma1123 replied at 2024-04-18 00:26:06
100 points EXCELLENT
yes issue might be on share-domain, and connection speed.
Author: duncanb7 replied at 2024-04-18 00:23:23
The follows is my php information from my domain, the max memory is 128M , Is it cache memory ?
==================
PHP Configuration
These PHP configuration settings are customizable by the server administrator. They are listed for reference only.
Sub Section Directive Info Value
Language Options asp_tags Allow ASP-style <% %> tags. Off
File Uploads file_uploads Whether to allow HTTP file uploads. On
Paths and Directories include_path Windows: "path1;path2" c:phpincludes" .:/usr/lib/php:/usr/local/lib/php
Resource Limits max_execution_time 30
Resource Limits max_input_time 60
Resource Limits memory_limit 128M
Data Handling register_globals You should do your best to write your scripts so that they do not require register_globals to be on; Using form variables as globals can easily lead to possible security problems, if the code is not very well thought of. Off
Language Options safe_mode Off
main session.save_path Argument passed to save_handler. In the case of files, this is the path where data files are stored. Note: Windows users have to change this variable in order to use PHP's session functions. As of PHP 4.0.1, you can define the path as: session.save_path = "N;/path" where N is an integer. Instead of storing all the session files in /path, what this will do is use subdirectories N-levels deep, and store the session data in those directories. This is useful if you or your OS have problems with lots of files in one directory, and is a more efficient layout for servers that handle lots of sessions. NOTE 1: PHP will not create this directory structure automatically. You can use the script in the ext/session dir for that purpose. NOTE 2: See the section on garbage collection below if you choose to use subdirectories for session storage /tmp
File Uploads upload_max_filesize Maximum allowed size for uploaded files. 128M
==================
PHP Configuration
These PHP configuration settings are customizable by the server administrator. They are listed for reference only.
Sub Section Directive Info Value
Language Options asp_tags Allow ASP-style <% %> tags. Off
File Uploads file_uploads Whether to allow HTTP file uploads. On
Paths and Directories include_path Windows: "path1;path2" c:phpincludes" .:/usr/lib/php:/usr/local/lib/php
Resource Limits max_execution_time 30
Resource Limits max_input_time 60
Resource Limits memory_limit 128M
Data Handling register_globals You should do your best to write your scripts so that they do not require register_globals to be on; Using form variables as globals can easily lead to possible security problems, if the code is not very well thought of. Off
Language Options safe_mode Off
main session.save_path Argument passed to save_handler. In the case of files, this is the path where data files are stored. Note: Windows users have to change this variable in order to use PHP's session functions. As of PHP 4.0.1, you can define the path as: session.save_path = "N;/path" where N is an integer. Instead of storing all the session files in /path, what this will do is use subdirectories N-levels deep, and store the session data in those directories. This is useful if you or your OS have problems with lots of files in one directory, and is a more efficient layout for servers that handle lots of sessions. NOTE 1: PHP will not create this directory structure automatically. You can use the script in the ext/session dir for that purpose. NOTE 2: See the section on garbage collection below if you choose to use subdirectories for session storage /tmp
File Uploads upload_max_filesize Maximum allowed size for uploaded files. 128M
Assisted Solution
Expert: mattibutt replied at 2024-04-18 00:10:04
100 points EXCELLENT
Can you check what is the allocated max memory for php in phpinfo file if you.are required to a lot of php generated tables then use cache or gzip compression to improve your php performance from my view any view you are creating should on client side this means server doesn't have to do any excessive memory consumption task.
Author: duncanb7 replied at 2024-04-18 00:05:02
So it means my php code is not issue to the speed on the server, the issue might be my share-domain ?
Accepted Solution
Expert: roma1123 replied at 2024-04-18 00:00:45
100 points EXCELLENT
The code written in php will depend on the Server computer performance.
Javascript will depend on user's computer performance + browser.
I would suggest you to use PHP because you never know which performance will have the user that is visiting your site.
Javascript will depend on user's computer performance + browser.
I would suggest you to use PHP because you never know which performance will have the user that is visiting your site.