[ Tin nhắn mới · Thành viên · Quy tắc diễn đàn · Tìm kiếm · RSS]
THỐNG KÊ DIỄN ĐÀN
BÀI VIẾT MỚICHỦ ĐỀ SÔI ĐỘNGTHÀNH VIÊN TÍCH CỰCTHÀNH VIÊN MỚI
  • Chồng Nhâm Thâ... (1)
  • Bộ sách về tử ... (1)
  • Thuốc chữa bện... (1)
  • Bệnh nhiệt miệ... (0)
  • Tạo màng ngăn ... (0)
  • Tổng Hợp về YA... (13)
  • Tăng font chữ ... (13)
  • Tử vi năm Nhâm... (11)
  • Phong thủy cho... (10)
  • Thái cực quyền... (8)
  • TieuBao
  • kcdl
  • havanchan55
  • minzjkute
  • 12a3
  • adjmkun60
  • thaybalau
  • huyenntn17fsoft
  • trininh0610
  • linhphuongcva
    • Page 1 of 1
    • 1
    DIỄN ĐÀN_VNTAMTAY » THƯ VIỆN WEBSITE » MÃ HTML & JAVASCRIPT » 7 lời khuyên làm tăng tốc website (7 lời khuyên làm tăng tốc website)
    7 lời khuyên làm tăng tốc website
    TieuBaoNgày: Thứ 3, 30-Aug-11, 20:54:33 | Bài viết # 1


    Nhóm: Administrator
    Số bài viết: 3090
    Khen thưởng: 3
    Được cảm ơn: 10001
    Trạng thái: Offline
    Sau đây là những lời khuyên làm tối ưu hóa website của bạn,giúp cho website load nhanh hơn ,tiết kiệm thời gian tải dữ liệu.Tài liệu bằng tiếng anh,nhưng rất hay,các bạn từ từ xem nhé
    1. sizeof vs count

    First up are the sizeof and count functions. They can both be used to count the number of items in an array but does one do it better?

    sizeof vs count
    sizeof: 3.75928902626 seconds
    count: 3.33035206795 seconds
    Time saved: 0.428936958313 seconds; 12.8796280262%

    The evidence says yes. The count function was over 12% faster in this test. Both functions are fast though taking 3-4 microseconds to count an array with 100,000 items. You might think it isn't worth it but remember count is also a character shorter. Not only is it faster to run but it is also faster to type!

    2. is_int vs is_integer

    Next it is time to try some validation with is_int and is_integer.

    is_int vs is_integer
    is_int: 3.11394786835 seconds
    is_integer: 3.42630600929 seconds
    Time saved: 0.312358140945 seconds; 9.11646946006%

    The difference is smaller this time but again both functions are executing in a little over 3 microseconds. is_int is faster than is_integer so again the shorter function name wins. Is this going to be a pattern?

    3. chop vs rtrim

    Tidying up a string breaks the pattern. Maybe my analysis was a little premature.

    chop vs rtrim
    chop: 4.73731994629 seconds
    rtrim: 4.41647195816 seconds
    Time saved: 0.320847988129 seconds; 7.26480301852%

    rtrim is a little faster and these functions take longer at a little over 4 microseconds.

    4. doubleval vs floatval

    Both these functions allow you to quickly pick a float, or double, out of a string.

    doubleval vs floatval
    doubleval: 4.56571412086 seconds
    floatval: 4.35375285149 seconds
    Time saved: 0.211961269379 seconds; 4.8684727087%

    4% or 211 nanoseconds is next to nothing. I would want to use floatval but I wouldn't exactly be kicking myself if I slipped a doubleval into my code instead.

    5. fwrite vs fputs

    So far all the functions have been running fast anyway so the difference haven't been that significant but things are starting to get interesting with the run time jumping to 20-24 microseconds to write a short string to a file.

    fwrite vs fputs
    fwrite: 24.9826359749 seconds
    fputs: 20.1990799904 seconds
    Time saved: 4.7835559845 seconds; 23.6820488199%

    With a difference of over 4 microseconds you could run both fputs and floatval in the time it takes to run fwrite. The difference is over 23% which clearly makes fputs the better function. It's shorter as well.

    6. implode vs join

    This one really surprised me. I expected these functions to be faster. Both these functions allow you to convert an array into a string. implode is the opposite of explode and join allows you to join the items in an array with a 'glue' string. In this case the array had 100 items.

    implode vs join
    implode: 47.2712550163 seconds
    join: 50.1287050247 seconds
    Time saved: 2.85745000839 seconds; 5.70022705949%

    5% doesn't seem like all that much but 2 microseconds shouldn't be ignored.

    7. ini_alter vs ini_set

    Finally lets look at modifying the environment. I actually cheated here and just set the max execution time to 60 seconds a million times. I think the result is still valid though

    ini_alter vs ini_set
    ini_alter: 103.332370043 seconds
    ini_set: 86.2883789539 seconds
    Time saved: 17.0439910889 seconds; 19.7523598143%

    As might be expected these functions are expensive when it comes to execution time. That 17 microsecond saving is massive as well making ini_set the superior choice.


    TRẺ DÙNG SỨC KHỎE KIẾM TIỀN-GIÁ DÙNG TIỀN MUA SỨC KHỎE

    NHỮNG GÌ CON NGƯỜI KHÔNG NGHĨ TỚI LẠI XẢY RA TRONG ĐỜI
     
    DIỄN ĐÀN_VNTAMTAY » THƯ VIỆN WEBSITE » MÃ HTML & JAVASCRIPT » 7 lời khuyên làm tăng tốc website (7 lời khuyên làm tăng tốc website)
    • Page 1 of 1
    • 1
    Search:

    click ủng hộ vntamtay
    Chát với Tôi
    300
    Liên kết quảng cáo
    Buôn bán phụ tùng!
    Đang truy cập
    Khu đăng nhập
    Video Clip
    00:00:24

    cat attack dog

    • Views:
    • Total comments: 0
    • Rating: 0.0
    Tỷ giá tiền tệ