コード例 #1
0
ファイル: Format.php プロジェクト: rkeplin/zf2
    /**
     * Returns a locale formatted number depending on the given options.
     * The seperation and fraction sign is used from the set locale.
     * ##0.#  -> 12345.12345 -> 12345.12345
     * ##0.00 -> 12345.12345 -> 12345.12
     * ##,##0.00 -> 12345.12345 -> 12,345.12
     *
     * @param   string  $input    Localized number string
     * @param   array   $options  Options: number_format, locale, precision. See {@link setOptions()} for details.
     * @throws \Zend\Locale\Exception\InvalidArgumentException
     * @return  string  locale formatted number
     */
    public static function toNumber($value, array $options = array())
    {
        $value             = Math::normalize($value);
        $value             = Math::floatalize($value);
        $options           = self::_checkOptions($options) + self::$_options;
        $options['locale'] = (string) $options['locale'];

        // Get correct signs for this locale
        $symbols = Cldr::getList($options['locale'], 'symbols');
        $oenc = iconv_get_encoding('internal_encoding');
        iconv_set_encoding('internal_encoding', 'UTF-8');

        // Get format
        $format = $options['number_format'];
        if ($format === null) {
            $format  = Cldr::getContent($options['locale'], 'decimalnumber');
            $format  = self::_seperateFormat($format, $value, $options['precision']);

            if ($options['precision'] !== null) {
                $value   = Math::normalize(Math::round($value, $options['precision']));
            }
        } else {
            // seperate negative format pattern when available
            $format  = self::_seperateFormat($format, $value, $options['precision']);
            if (strpos($format, '.')) {
                if (is_numeric($options['precision'])) {
                    $value = Math::round($value, $options['precision']);
                } else {
                    if (substr($format, iconv_strpos($format, '.') + 1, 3) == '###') {
                        $options['precision'] = null;
                    } else {
                        $options['precision'] = iconv_strlen(iconv_substr($format, iconv_strpos($format, '.') + 1,
                                                             iconv_strrpos($format, '0') - iconv_strpos($format, '.')));
                        $format = iconv_substr($format, 0, iconv_strpos($format, '.') + 1) . '###'
                                . iconv_substr($format, iconv_strrpos($format, '0') + 1);
                    }
                }
            } else {
                $value = Math::round($value, 0);
                $options['precision'] = 0;
            }
            $value = Math::normalize($value);
        }

        if (iconv_strpos($format, '0') === false) {
            iconv_set_encoding('internal_encoding', $oenc);
            throw new Exception\InvalidArgumentException(
              'Wrong format... missing 0'
            );
        }

        // get number parts
        $pos = iconv_strpos($value, '.');
        if ($pos !== false) {
            if ($options['precision'] === null) {
                $precstr = iconv_substr($value, $pos + 1);
            } else {
                $precstr = iconv_substr($value, $pos + 1, $options['precision']);
                if (iconv_strlen($precstr) < $options['precision']) {
                    $precstr = $precstr . str_pad("0", ($options['precision'] - iconv_strlen($precstr)), "0");
                }
            }
        } else {
            if ($options['precision'] > 0) {
                $precstr = str_pad("0", ($options['precision']), "0");
            }
        }

        if ($options['precision'] === null) {
            if (isset($precstr)) {
                $options['precision'] = iconv_strlen($precstr);
            } else {
                $options['precision'] = 0;
            }
        }

        // get fraction and format lengths
        if (strpos($value, '.') !== false) {
            $number = substr((string) $value, 0, strpos($value, '.'));
        } else {
            $number = $value;
        }

        $prec = call_user_func(Math::$sub, $value, $number, $options['precision']);
        $prec = Math::floatalize($prec);
        $prec = Math::normalize($prec);
        if (iconv_strpos($prec, '-') !== false) {
            $prec = iconv_substr($prec, 1);
        }

        if (($prec == 0) and ($options['precision'] > 0)) {
            $prec = "0.0";
        }

        if (($options['precision'] + 2) > iconv_strlen($prec)) {
            $prec = str_pad((string) $prec, $options['precision'] + 2, "0", STR_PAD_RIGHT);
        }

        if (iconv_strpos($number, '-') !== false) {
            $number = iconv_substr($number, 1);
        }
        $group  = iconv_strrpos($format, ',');
        $group2 = iconv_strpos ($format, ',');
        $point  = iconv_strpos ($format, '0');
        // Add fraction
        $rest = "";
        if (iconv_strpos($format, '.')) {
            $rest   = iconv_substr($format, iconv_strpos($format, '.') + 1);
            $length = iconv_strlen($rest);
            for($x = 0; $x < $length; ++$x) {
                if (($rest[0] == '0') || ($rest[0] == '#')) {
                    $rest = iconv_substr($rest, 1);
                }
            }
            $format = iconv_substr($format, 0, iconv_strlen($format) - iconv_strlen($rest));
        }

        if ($options['precision'] == '0') {
            if (iconv_strrpos($format, '-') != 0) {
                $format = iconv_substr($format, 0, $point)
                        . iconv_substr($format, iconv_strrpos($format, '#') + 2);
            } else {
                $format = iconv_substr($format, 0, $point);
            }
        } else {
            $format = iconv_substr($format, 0, $point) . $symbols['decimal']
                               . iconv_substr($prec, 2);
        }

        $format .= $rest;
        // Add seperation
        if ($group == 0) {
            // no seperation
            $format = $number . iconv_substr($format, $point);
        } else if ($group == $group2) {
            // only 1 seperation
            $seperation = ($point - $group);
            for ($x = iconv_strlen($number); $x > $seperation; $x -= $seperation) {
                if (iconv_substr($number, 0, $x - $seperation) !== "") {
                    $number = iconv_substr($number, 0, $x - $seperation) . $symbols['group']
                            . iconv_substr($number, $x - $seperation);
                }
            }
            $format = iconv_substr($format, 0, iconv_strpos($format, '#')) . $number . iconv_substr($format, $point);
        } else {

            // 2 seperations
            if (iconv_strlen($number) > ($point - $group)) {
                $seperation = ($point - $group);
                $number = iconv_substr($number, 0, iconv_strlen($number) - $seperation) . $symbols['group']
                        . iconv_substr($number, iconv_strlen($number) - $seperation);

                if ((iconv_strlen($number) - 1) > ($point - $group + 1)) {
                    $seperation2 = ($group - $group2 - 1);
                    for ($x = iconv_strlen($number) - $seperation2 - 2; $x > $seperation2; $x -= $seperation2) {
                        $number = iconv_substr($number, 0, $x - $seperation2) . $symbols['group']
                                . iconv_substr($number, $x - $seperation2);
                    }
                }

            }
            $format = iconv_substr($format, 0, iconv_strpos($format, '#')) . $number . iconv_substr($format, $point);
        }
        // set negative sign
        if (call_user_func(Math::$comp, $value, 0, $options['precision']) < 0) {
            if (iconv_strpos($format, '-') === false) {
                $format = $symbols['minus'] . $format;
            } else {
                $format = str_replace('-', $symbols['minus'], $format);
            }
        }

        iconv_set_encoding('internal_encoding', $oenc);
        return (string) $format;
    }
コード例 #2
0
 public function getMetricsFromBytes($bs, &$output)
 {
     $output = $output;
     $width = 0;
     $height = 0;
     $dpi = 0;
     $baseline = 0;
     $bys = haxe_io_Bytes::ofData($bs);
     $bi = new haxe_io_BytesInput($bys, null, null);
     $n = $bys->length;
     $alloc = 10;
     $b = haxe_io_Bytes::alloc($alloc);
     $bi->readBytes($b, 0, 8);
     $n -= 8;
     while ($n > 0) {
         $len = com_wiris_system_InputEx::readInt32_($bi);
         $typ = com_wiris_system_InputEx::readInt32_($bi);
         if ($typ === 1229472850) {
             $width = com_wiris_system_InputEx::readInt32_($bi);
             $height = com_wiris_system_InputEx::readInt32_($bi);
             com_wiris_system_InputEx::readInt32_($bi);
             $bi->readByte();
         } else {
             if ($typ === 1650545477) {
                 $baseline = com_wiris_system_InputEx::readInt32_($bi);
             } else {
                 if ($typ === 1883789683) {
                     $dpi = com_wiris_system_InputEx::readInt32_($bi);
                     $dpi = Math::round($dpi / 39.37);
                     com_wiris_system_InputEx::readInt32_($bi);
                     $bi->readByte();
                 } else {
                     if ($len > $alloc) {
                         $alloc = $len;
                         $b = haxe_io_Bytes::alloc($alloc);
                     }
                     $bi->readBytes($b, 0, $len);
                 }
             }
         }
         com_wiris_system_InputEx::readInt32_($bi);
         $n -= $len + 12;
         unset($typ, $len);
     }
     $r = null;
     if ($output !== null) {
         $output["width"] = "" . _hx_string_rec($width, "");
         $output["height"] = "" . _hx_string_rec($height, "");
         $output["baseline"] = "" . _hx_string_rec($baseline, "");
         if ($dpi !== 96) {
             $output["dpi"] = "" . _hx_string_rec($dpi, "");
         }
         $r = "";
     } else {
         $r = "&cw=" . _hx_string_rec($width, "") . "&ch=" . _hx_string_rec($height, "") . "&cb=" . _hx_string_rec($baseline, "");
         if ($dpi !== 96) {
             $r = $r . "&dpi=" . _hx_string_rec($dpi, "");
         }
     }
     return $r;
 }
コード例 #3
0
ファイル: JSon.class.php プロジェクト: komcdo/winnow
 static function getInt($n)
 {
     if (Std::is($n, _hx_qtype("Float"))) {
         return Math::round($n);
     } else {
         if (Std::is($n, _hx_qtype("Int"))) {
             return $n;
         } else {
             return 0;
         }
     }
 }
コード例 #4
0
 public function alignCore2($align, $a, $b)
 {
     if ($align->meta === null) {
         $align->meta = new coopy_Alignment();
     }
     $this->alignColumns($align->meta, $a, $b);
     $column_order = $align->meta->toOrder();
     $align->range($a->get_height(), $b->get_height());
     $align->tables($a, $b);
     $align->setRowlike(true);
     $w = $a->get_width();
     $ha = $a->get_height();
     $hb = $b->get_height();
     $av = $a->getCellView();
     $ids = null;
     $ignore = null;
     if ($this->comp->compare_flags !== null) {
         $ids = $this->comp->compare_flags->ids;
         $ignore = $this->comp->compare_flags->getIgnoredColumns();
     }
     $common_units = new _hx_array(array());
     $ra_header = $align->getSourceHeader();
     $rb_header = $align->getSourceHeader();
     $_g = 0;
     $_g1 = $column_order->getList();
     while ($_g < $_g1->length) {
         $unit = $_g1[$_g];
         ++$_g;
         if ($unit->l >= 0 && $unit->r >= 0 && $unit->p !== -1) {
             if ($ignore !== null) {
                 if ($unit->l >= 0 && $ra_header >= 0 && $ra_header < $a->get_height()) {
                     $name = $av->toString($a->getCell($unit->l, $ra_header));
                     if ($ignore->exists($name)) {
                         continue;
                     }
                     unset($name);
                 }
                 if ($unit->r >= 0 && $rb_header >= 0 && $rb_header < $b->get_height()) {
                     $name1 = $av->toString($b->getCell($unit->r, $rb_header));
                     if ($ignore->exists($name1)) {
                         continue;
                     }
                     unset($name1);
                 }
             }
             $common_units->push($unit);
         }
         unset($unit);
     }
     $index_top = null;
     $pending_ct = $ha;
     $reverse_pending_ct = $hb;
     $used = new haxe_ds_IntMap();
     $used_reverse = new haxe_ds_IntMap();
     if ($ids !== null) {
         $index_top = new coopy_IndexPair($this->comp->compare_flags);
         $ids_as_map = new haxe_ds_StringMap();
         $_g2 = 0;
         while ($_g2 < $ids->length) {
             $id = $ids[$_g2];
             ++$_g2;
             $ids_as_map->set($id, true);
             true;
             unset($id);
         }
         $_g3 = 0;
         while ($_g3 < $common_units->length) {
             $unit1 = $common_units[$_g3];
             ++$_g3;
             $na = $av->toString($a->getCell($unit1->l, 0));
             $nb = $av->toString($b->getCell($unit1->r, 0));
             if ($ids_as_map->exists($na) || $ids_as_map->exists($nb)) {
                 $index_top->addColumns($unit1->l, $unit1->r);
                 $align->addIndexColumns($unit1);
             }
             unset($unit1, $nb, $na);
         }
         $index_top->indexTables($a, $b, 1);
         if ($this->indexes !== null) {
             $this->indexes->push($index_top);
         }
         $_g4 = 0;
         while ($_g4 < $ha) {
             $j = $_g4++;
             $cross = $index_top->queryLocal($j);
             $spot_a = $cross->spot_a;
             $spot_b = $cross->spot_b;
             if ($spot_a !== 1 || $spot_b !== 1) {
                 continue;
             }
             $jb = $cross->item_b->lst[0];
             $align->link($j, $jb);
             $used->set($jb, 1);
             if (!$used_reverse->exists($j)) {
                 $reverse_pending_ct--;
             }
             $used_reverse->set($j, 1);
             unset($spot_b, $spot_a, $jb, $j, $cross);
         }
     } else {
         $N = 5;
         $columns = new _hx_array(array());
         if ($common_units->length > $N) {
             $columns_eval = new _hx_array(array());
             $_g11 = 0;
             $_g5 = $common_units->length;
             while ($_g11 < $_g5) {
                 $i = $_g11++;
                 $ct = 0;
                 $mem = new haxe_ds_StringMap();
                 $mem2 = new haxe_ds_StringMap();
                 $ca = _hx_array_get($common_units, $i)->l;
                 $cb = _hx_array_get($common_units, $i)->r;
                 $_g21 = 0;
                 while ($_g21 < $ha) {
                     $j1 = $_g21++;
                     $key = $av->toString($a->getCell($ca, $j1));
                     if (!$mem->exists($key)) {
                         $mem->set($key, 1);
                         $ct++;
                     }
                     unset($key, $j1);
                 }
                 unset($_g21);
                 $_g22 = 0;
                 while ($_g22 < $hb) {
                     $j2 = $_g22++;
                     $key1 = $av->toString($b->getCell($cb, $j2));
                     if (!$mem2->exists($key1)) {
                         $mem2->set($key1, 1);
                         $ct++;
                     }
                     unset($key1, $j2);
                 }
                 unset($_g22);
                 $columns_eval->push(new _hx_array(array($i, $ct)));
                 unset($mem2, $mem, $i, $ct, $cb, $ca);
             }
             $sorter = array(new _hx_lambda(array(&$N, &$a, &$align, &$av, &$b, &$column_order, &$columns, &$columns_eval, &$common_units, &$ha, &$hb, &$ids, &$ignore, &$index_top, &$pending_ct, &$ra_header, &$rb_header, &$reverse_pending_ct, &$used, &$used_reverse, &$w), "coopy_CompareTable_0"), 'execute');
             $columns_eval->sort($sorter);
             $columns = Lambda::harray(Lambda::map($columns_eval, array(new _hx_lambda(array(&$N, &$a, &$align, &$av, &$b, &$column_order, &$columns, &$columns_eval, &$common_units, &$ha, &$hb, &$ids, &$ignore, &$index_top, &$pending_ct, &$ra_header, &$rb_header, &$reverse_pending_ct, &$sorter, &$used, &$used_reverse, &$w), "coopy_CompareTable_1"), 'execute')));
             $columns = $columns->slice(0, $N);
         } else {
             $_g12 = 0;
             $_g6 = $common_units->length;
             while ($_g12 < $_g6) {
                 $i1 = $_g12++;
                 $columns->push($i1);
                 unset($i1);
             }
         }
         $top = Math::round(Math::pow(2, $columns->length));
         $pending = new haxe_ds_IntMap();
         $_g7 = 0;
         while ($_g7 < $ha) {
             $j3 = $_g7++;
             $pending->set($j3, $j3);
             unset($j3);
         }
         $added_columns = new haxe_ds_IntMap();
         $index_ct = 0;
         $_g8 = 0;
         while ($_g8 < $top) {
             $k = $_g8++;
             if ($k === 0) {
                 continue;
             }
             if ($pending_ct === 0) {
                 break;
             }
             $active_columns = new _hx_array(array());
             $kk = $k;
             $at = 0;
             while ($kk > 0) {
                 if (_hx_mod($kk, 2) === 1) {
                     $active_columns->push($columns[$at]);
                 }
                 $kk >>= 1;
                 $at++;
             }
             $index = new coopy_IndexPair($this->comp->compare_flags);
             $_g23 = 0;
             $_g13 = $active_columns->length;
             while ($_g23 < $_g13) {
                 $k1 = $_g23++;
                 $col = $active_columns[$k1];
                 $unit2 = $common_units[$col];
                 $index->addColumns($unit2->l, $unit2->r);
                 if (!$added_columns->exists($col)) {
                     $align->addIndexColumns($unit2);
                     $added_columns->set($col, true);
                 }
                 unset($unit2, $k1, $col);
             }
             unset($_g23, $_g13);
             $index->indexTables($a, $b, 1);
             if ($k === $top - 1) {
                 $index_top = $index;
             }
             $h = $a->get_height();
             if ($b->get_height() > $h) {
                 $h = $b->get_height();
             }
             if ($h < 1) {
                 $h = 1;
             }
             $wide_top_freq = $index->getTopFreq();
             $ratio = $wide_top_freq;
             $ratio /= $h + 20;
             if ($ratio >= 0.1) {
                 if ($index_ct > 0 || $k < $top - 1) {
                     continue;
                 }
             }
             $index_ct++;
             if ($this->indexes !== null) {
                 $this->indexes->push($index);
             }
             $fixed = new _hx_array(array());
             if (null == $pending) {
                 throw new HException('null iterable');
             }
             $__hx__it = $pending->keys();
             while ($__hx__it->hasNext()) {
                 unset($j4);
                 $j4 = $__hx__it->next();
                 $cross1 = $index->queryLocal($j4);
                 $spot_a1 = $cross1->spot_a;
                 $spot_b1 = $cross1->spot_b;
                 if ($spot_a1 !== 1 || $spot_b1 !== 1) {
                     continue;
                 }
                 $val = $cross1->item_b->lst[0];
                 if (!$used->exists($val)) {
                     $fixed->push($j4);
                     $align->link($j4, $val);
                     $used->set($val, 1);
                     if (!$used_reverse->exists($j4)) {
                         $reverse_pending_ct--;
                     }
                     $used_reverse->set($j4, 1);
                 }
                 unset($val, $spot_b1, $spot_a1, $cross1);
             }
             $_g24 = 0;
             $_g14 = $fixed->length;
             while ($_g24 < $_g14) {
                 $j5 = $_g24++;
                 $pending->remove($fixed[$j5]);
                 $pending_ct--;
                 unset($j5);
             }
             unset($_g24, $_g14);
             unset($wide_top_freq, $ratio, $kk, $k, $index, $h, $fixed, $at, $active_columns);
         }
     }
     if ($index_top !== null) {
         $offset = 0;
         $scale = 1;
         $_g9 = 0;
         while ($_g9 < 2) {
             $sgn = $_g9++;
             if ($pending_ct > 0) {
                 $xb = null;
                 if ($scale === -1 && $hb > 0) {
                     $xb = $hb - 1;
                 }
                 $_g15 = 0;
                 while ($_g15 < $ha) {
                     $xa0 = $_g15++;
                     $xa = $xa0 * $scale + $offset;
                     $xb2 = $align->a2b($xa);
                     if ($xb2 !== null) {
                         $xb = $xb2 + $scale;
                         if ($xb >= $hb || $xb < 0) {
                             break;
                         }
                         continue;
                     }
                     if ($xb === null) {
                         continue;
                     }
                     $ka = $index_top->localKey($xa);
                     $kb = $index_top->remoteKey($xb);
                     if ($ka !== $kb) {
                         continue;
                     }
                     if ($used->exists($xb)) {
                         continue;
                     }
                     $align->link($xa, $xb);
                     $used->set($xb, 1);
                     $used_reverse->set($xa, 1);
                     $pending_ct--;
                     $xb += $scale;
                     if ($xb >= $hb || $xb < 0) {
                         break;
                     }
                     if ($pending_ct === 0) {
                         break;
                     }
                     unset($xb2, $xa0, $xa, $kb, $ka);
                 }
                 unset($_g15);
                 unset($xb);
             }
             $offset = $ha - 1;
             $scale = -1;
             unset($sgn);
         }
         $offset = 0;
         $scale = 1;
         $_g10 = 0;
         while ($_g10 < 2) {
             $sgn1 = $_g10++;
             if ($reverse_pending_ct > 0) {
                 $xa1 = null;
                 if ($scale === -1 && $ha > 0) {
                     $xa1 = $ha - 1;
                 }
                 $_g16 = 0;
                 while ($_g16 < $hb) {
                     $xb0 = $_g16++;
                     $xb1 = $xb0 * $scale + $offset;
                     $xa2 = $align->b2a($xb1);
                     if ($xa2 !== null) {
                         $xa1 = $xa2 + $scale;
                         if ($xa1 >= $ha || $xa1 < 0) {
                             break;
                         }
                         continue;
                     }
                     if ($xa1 === null) {
                         continue;
                     }
                     $ka1 = $index_top->localKey($xa1);
                     $kb1 = $index_top->remoteKey($xb1);
                     if ($ka1 !== $kb1) {
                         continue;
                     }
                     if ($used_reverse->exists($xa1)) {
                         continue;
                     }
                     $align->link($xa1, $xb1);
                     $used->set($xb1, 1);
                     $used_reverse->set($xa1, 1);
                     $reverse_pending_ct--;
                     $xa1 += $scale;
                     if ($xa1 >= $ha || $xa1 < 0) {
                         break;
                     }
                     if ($reverse_pending_ct === 0) {
                         break;
                     }
                     unset($xb1, $xb0, $xa2, $kb1, $ka1);
                 }
                 unset($_g16);
                 unset($xa1);
             }
             $offset = $hb - 1;
             $scale = -1;
             unset($sgn1);
         }
     }
     $_g17 = 1;
     while ($_g17 < $ha) {
         $i2 = $_g17++;
         if (!$used_reverse->exists($i2)) {
             $align->link($i2, -1);
         }
         unset($i2);
     }
     $_g18 = 1;
     while ($_g18 < $hb) {
         $i3 = $_g18++;
         if (!$used->exists($i3)) {
             $align->link(-1, $i3);
         }
         unset($i3);
     }
     if ($ha > 0 && $hb > 0) {
         $align->link(0, 0);
     }
 }
コード例 #5
0
ファイル: SunCalc.class.php プロジェクト: ypid/suncalc-php
 static function getTimes($date, $lat, $lng)
 {
     $lw = suncalc_SunCalc::$rad * -$lng;
     $phi = suncalc_SunCalc::$rad * $lat;
     $d = suncalc_SunCalc::toDays($date);
     $n = Math::round($d - suncalc_SunCalc::$J0 - $lw / (2 * Math::$PI));
     $ds = suncalc_SunCalc::approxTransit(0, $lw, $n);
     $M = suncalc_SunCalc::solarMeanAnomaly($ds);
     $L = suncalc_SunCalc::eclipticLongitude($M);
     $dec = suncalc_SunCalc::declination($L, 0);
     $Jnoon = suncalc_SunCalc::solarTransitJ($ds, $M, $L);
     $i = null;
     $len = null;
     $time = null;
     $Jset = null;
     $Jrise = null;
     $result = new haxe_ds_StringMap();
     $v = suncalc_SunCalc::fromJulian($Jnoon);
     $result->set("solarNoon", $v);
     $v;
     $v1 = suncalc_SunCalc::fromJulian($Jnoon - 0.5);
     $result->set("nadir", $v1);
     $v1;
     $_g = 0;
     $_g1 = suncalc_SunCalc::$times;
     while ($_g < $_g1->length) {
         $time1 = $_g1[$_g];
         ++$_g;
         $Jset = suncalc_SunCalc::getSetJ($time1->a[0] * suncalc_SunCalc::$rad, $lw, $phi, $dec, $n, $M, $L);
         $Jrise = $Jnoon - ($Jset - $Jnoon);
         $k = $time1[1];
         $v2 = suncalc_SunCalc::fromJulian($Jrise);
         $result->set($k, $v2);
         $v2;
         unset($v2, $k);
         $k1 = $time1[2];
         $v3 = suncalc_SunCalc::fromJulian($Jset);
         $result->set($k1, $v3);
         $v3;
         unset($v3, $k1);
         unset($time1);
     }
     return $result;
 }
コード例 #6
0
ファイル: Pcall.class.php プロジェクト: marcdraco/Webrathea
 public function percentf($t_stop = null)
 {
     return Std::string(Math::round($this->percent($t_stop))) . "%";
 }
コード例 #7
0
ファイル: Cache.class.php プロジェクト: marcdraco/Webrathea
 static function format_profiler_message($type, $instance)
 {
     $t = new StringBuf();
     if ($instance->calls > 0) {
         $t->add("<td>" . _hx_string_or_null($type) . "</td>");
         $t->add("<td>" . Std::string($instance->calls) . "</td>");
         $t->add("<td>" . _hx_string_or_null(system_base_Database::sprint_float($instance->time, 6)) . "</td>");
         $t->add("<td class=\"__hand__\" title = '" . Std::string($instance->fast_sql) . "'>" . _hx_string_or_null(system_base_Database::sprint_float($instance->fast, 6)) . "</td>");
         $t->add("<td class=\"__hand__\" title = '" . Std::string($instance->slow_sql) . "'>" . _hx_string_or_null(system_base_Database::sprint_float($instance->slow, 6)) . "</td>");
         $t->add("<td>" . Std::string($instance->percentf(null)) . "</td>");
         $t->add("<td>" . Std::string(Math::round($instance->percent(null) / $instance->calls)) . "%</td>");
         return $t->b;
     } else {
         $t->add("<td>" . _hx_string_or_null($type) . "</td>");
         $t->add("<td></td>");
         $t->add("<td></td>");
         $t->add("<td></td>");
         $t->add("<td></td>");
         $t->add("<td></td>");
         $t->add("<td></td>");
         return $t->b;
     }
 }