Tutoriale PHP
  Comunitatea PHP Romania

 
Tutoriale PHP
Index » Noutati

David Otton's Blog: php://memory, Unit Tests


Postat:Marti 18 Noiembrie 2008 21:42
Accesari:17
Comentarii:0
Favorite:0
Sursa: http://www.phpdeveloper.org

Del.icio.us
Digg
Technorati
Categorii: Noutati | alfahost_ro

In looking to test his fputscsv functionality, David Otton found a simple way to measure its performance by using streams.

Then I realised I could use PHP's (fairly) new IO streams to dump the function's output to a temporary buffer, and read it back in for comparison. Not perfect, but it removes concerns about file mutexes, permissions, unique filenames, etc. and speeds up the tests, as they never touch disc.

He uses a custom stream and points it to php://memory to store and read the data from. Code is included in the post as well as example usage. It runs an assert that the value pushed into another memory chunk is the same as the first one (ensuring that the results of his fputcsv calls are valid).

Comentarii


    Ultimele discutii in forum RSS Forum

    Ultimele articole Ultimele articole

    Top membri

    Pirahna Pirahna
    la birou
    carco carco
    Bucuresti
    Birkoff Birkoff
    Bucuresti
    mihaitha mihaitha
    Sibiu
    Mascka Mascka
    Braila
    gabysolomon gabysolomon
    Bacau
    whooper whooper
    Toronto ON
    raul_ raul_
    dechim dechim
    Drobeta Turnu Severin
    Amenthes Amenthes

    Newsletter


    Email:
     inscriere
     renuntare
     
     Arhiva newsletter

    Site-ul lunii

    blg
     Blgpunctro

    Propune un site

    Online

    330 utilizatori online

    Parteneriat



    Copyright © 2001-2009 PHP Romania Add PHPRomania to Google Add PHPRomania to Del.icio.us Add PHPRomania to Stumbleupon Add PHPRomania to Yahoo! Add PHPRomania to Digg Add PHPRomania to Blink MPAA | Cardcaptor Sakura Episodes | Money News | Debt Consolidation | Myspace Comments
    Ads: Partener Way2Web Nework: gazduire web | inregistrare domenii | web design | imobiliare | web hosting
    Powered by Simplis