English 中文(简体)
能否确定许多常态造成业绩或记忆问题?
原标题:Can defining a lot of constants cause performance or memory problems?

我有一个网站,使用许多固定不变,例如:

define( CONSTANT , 1)

我目前有大约200个定义。 这一清单每当页装上。 这是否会影响我的表现或记忆?

最佳回答

有理由避免每个页数上200个固定数,但业绩和记忆使用不会包括在内。 总的来说,回答这些问题的最好办法是制定基准。 测量页面负荷时间和记忆使用量,同时不装上200个不变值。 衡量数 000次,研究数字。 我怀疑你们的伤口是微不足道的。 小额贷款通常是浪费时间。

问题回答

我想不要。 你们是否有业绩问题? 否则,就不担心。 如果是的话,那么你又做了些什么来确定瓶颈在哪里?

如果你需要知道,把档案列入你的定义,并将之与你分开,那么我就建议你这样做。

$start = microtime (true);
include ( file_to_include.php );
echo (microtime (true) - $start);

为什么所有定义? 如果交通很多,这只会使你减慢。 如果你把他们全部投入使用,那么就可以看到,这种速度放慢了。 原因可能是更好的办法(即永远不需要超过5个固定点)

I don t think it will have more impact than reading the file that contains 200 constants, then again it will be optimized by your disk cache. At least it is better than reading 200 constants from database. If you do care about performance, install an op cache, therefore, it will not require any additional parsing every time. For memory it depends on the type of your constants but it wont be much.





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签