<legend id='QqlSp'><style id='QqlSp'><dir id='QqlSp'><q id='QqlSp'></q></dir></style></legend>
  • <small id='QqlSp'></small><noframes id='QqlSp'>

        <bdo id='QqlSp'></bdo><ul id='QqlSp'></ul>

        <i id='QqlSp'><tr id='QqlSp'><dt id='QqlSp'><q id='QqlSp'><span id='QqlSp'><b id='QqlSp'><form id='QqlSp'><ins id='QqlSp'></ins><ul id='QqlSp'></ul><sub id='QqlSp'></sub></form><legend id='QqlSp'></legend><bdo id='QqlSp'><pre id='QqlSp'><center id='QqlSp'></center></pre></bdo></b><th id='QqlSp'></th></span></q></dt></tr></i><div id='QqlSp'><tfoot id='QqlSp'></tfoot><dl id='QqlSp'><fieldset id='QqlSp'></fieldset></dl></div>
        <tfoot id='QqlSp'></tfoot>
      1. 使用 PHP int 的开销是多少?

        What is the overhead of using PHP int?(使用 PHP int 的开销是多少?)
          • <bdo id='7iNkB'></bdo><ul id='7iNkB'></ul>
              <tfoot id='7iNkB'></tfoot>

                <tbody id='7iNkB'></tbody>

              <small id='7iNkB'></small><noframes id='7iNkB'>

            • <legend id='7iNkB'><style id='7iNkB'><dir id='7iNkB'><q id='7iNkB'></q></dir></style></legend>

                <i id='7iNkB'><tr id='7iNkB'><dt id='7iNkB'><q id='7iNkB'><span id='7iNkB'><b id='7iNkB'><form id='7iNkB'><ins id='7iNkB'></ins><ul id='7iNkB'></ul><sub id='7iNkB'></sub></form><legend id='7iNkB'></legend><bdo id='7iNkB'><pre id='7iNkB'><center id='7iNkB'></center></pre></bdo></b><th id='7iNkB'></th></span></q></dt></tr></i><div id='7iNkB'><tfoot id='7iNkB'></tfoot><dl id='7iNkB'><fieldset id='7iNkB'></fieldset></dl></div>
                  本文介绍了使用 PHP int 的开销是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我一直听说 PHP 有开销.例如,C++ int 在 32 位系统上使用 4 个字节,但 PHP int 使用更多.这个值是多少?

                  I keep hearing that PHP has overhead. For example a C++ int uses 4 Bytes on a 32 bit system but a PHP int uses more. What is this value?

                  推荐答案

                  我需要比评论更多的空间来扩展 mario 的发现,所以我将添加一个答案.

                  I need more space than a comment to expand on mario's findings so I'll add an answer instead.

                  C union 的大小将是其最大成员的大小(可能带有额外的字节以满足对齐约束).对于 zvalue_value,这将是具有三个指针大小的 obj(不包括这些指针指向的内存所需的内存):

                  The size of a C union will be the size of its largest member (possibly with extra bytes to satisfy alignment constraints). For zvalue_value, that would be the obj which has the size of three pointers (not including the memory required for what those pointers point to):

                  typedef struct _zend_object {
                      zend_class_entry *ce;
                      HashTable *properties;
                      HashTable *guards; /* protects from __get/__set ... recursion */
                  } zend_object;
                  

                  在 32 位系统上,zend_object 将占用 24 个字节,而在 64 位系统上将占用 48 个字节.因此,每个 zvalue_value 将至少占用 24 或 48 个字节,无论您在其中存储什么数据.还有消耗更多内存的变量的名称;一旦编译器完成,编译语言通常会丢弃名称并将值视为简单的字节序列(因此 double 占用八个字节, char 占用一个字节,等等..).

                  On a 32bit system, a zend_object will take 24 bytes while on a 64bit system it will take 48 bytes. So, every zvalue_value will take at least 24 or 48 bytes regardless of what data you store in it. There's also the name of the variable which consumes more memory; compiled languages generally discard the names once the compiler is done and treat values as simple sequences of bytes (so a double takes eight bytes, a char takes one byte, etc...).

                  关于您最近关于 PHP 布尔值的问题,一个简单的布尔值将消耗 24 或 48 个字节作为值,再加上几个字节作为名称,再加上 4 或 8 个字节作为 zend_unit, 加上四个(或八个)来表示这两个 zend_uchar:

                  With regards to your recent questions about PHP booleans, a simple boolean value will consume 24 or 48 bytes for the value, plus a few more bytes for the name, plus four or eight for the zend_unit, plus four (or eight) for the two zend_uchars in this:

                  struct _zval_struct {
                      /* Variable information */
                      zvalue_value value;     /* value */
                      zend_uint refcount__gc;
                      zend_uchar type;    /* active type */
                      zend_uchar is_ref__gc;
                  };
                  

                  由于对齐限制,zend_uchar 成员将占用四个(或八个)字节,几乎每个 CPU 都希望访问自然地址边界上的内存,这意味着 zend_uchar 成员将占用四个(或八个)字节code>struct 将占用 4 个字节或 8 个字节的内存(取决于 CPU 的自然字长和对齐约束).因此,布尔值将占用 36 到 72 字节的内存.

                  The zend_uchar members will chew up four (or eight) bytes due to alignment constraints, almost every CPU wants to access memory on natural address boundaries and that means that a single byte sized member of a struct will take up four bytes or eight bytes of memory (depending on the CPUs natural word size and alignment constraints). So, a boolean will take somewhere between 36 and 72 bytes of memory.

                  这篇关于使用 PHP int 的开销是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                    <legend id='W32tu'><style id='W32tu'><dir id='W32tu'><q id='W32tu'></q></dir></style></legend>
                      <tbody id='W32tu'></tbody>
                  1. <small id='W32tu'></small><noframes id='W32tu'>

                  2. <i id='W32tu'><tr id='W32tu'><dt id='W32tu'><q id='W32tu'><span id='W32tu'><b id='W32tu'><form id='W32tu'><ins id='W32tu'></ins><ul id='W32tu'></ul><sub id='W32tu'></sub></form><legend id='W32tu'></legend><bdo id='W32tu'><pre id='W32tu'><center id='W32tu'></center></pre></bdo></b><th id='W32tu'></th></span></q></dt></tr></i><div id='W32tu'><tfoot id='W32tu'></tfoot><dl id='W32tu'><fieldset id='W32tu'></fieldset></dl></div>

                      <bdo id='W32tu'></bdo><ul id='W32tu'></ul>
                      1. <tfoot id='W32tu'></tfoot>