开发者

Getting data is fast, but Flash displaying php data is slow, why?

开发者 https://www.devze.com 2022-12-13 15:30 出处:网络
In my database(mysql), I have a table which has 50k data(rows/records). I do a test using firebug, after playing the game, the call to load_score.php and save_score.php is around 380ms (millisecond).

In my database(mysql), I have a table which has 50k data(rows/records).

I do a test using firebug, after playing the game, the call to load_score.php and save_score.php is around 380ms (millisecond).

The save_score.php just a normal inserting, nothing much. The load_score.php, I use this query:

SELECT name, score
FROM `highscores`
WHERE id =1
LIMIT 0, 10
  • The resu开发者_StackOverflowlt returns 10 rows
  • the query returns in 0.0005 seconds (tested using phpmyadmin)
  • I echoed the data back to flash.

But on my game (flash), it tooks 11 seconds(count manually) to load and save the score. Why the time differences is so big?

Could it be the problem when Flash received php data, the process to display is slow??

Are there any others reasons on why the displaying take longer time??

(If you need more information, please let me know)

Firebug Testing Result:

================================================================
=       File       |   firebug time   |   actual/on web time   =
================================================================
=   load_score.php |      435 ms      | 5 seconds(before it calls save_score.php)
=   save_score.php |      643 ms      | 4-5 seconds(before displaying highscore table)
================================================================

So the total time to display the highscore = ~10 seconds


Not 'the' answer, but you might save up to 5 seconds by combining both requests into one. Have the save script also return the high score table. You will at least save half a second (transfer time reported by firebug) and maybe more if there's a delay in flash for some reason.

The comments above should point you in the right direction in solving or at least identifying the root cause.


Another approach is to use amfphp library and thus send/receive data in Flash native AMF format which Flash can fast way faster.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号