DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations

Trending

  • Java String Templates Today
  • How To Use the Node Docker Official Image
  • Payments Architecture - An Introduction
  • Five IntelliJ Idea Plugins That Will Change the Way You Code
  1. DZone
  2. Data Engineering
  3. Data
  4. Benchmarks: PHP Solr Response Data Handling

Benchmarks: PHP Solr Response Data Handling

Bas De Nooijer user avatar by
Bas De Nooijer
·
Mar. 01, 12 · Interview
Like (0)
Save
Tweet
Share
4.89K Views

Join the DZone community and get the full member experience.

Join For Free

Solr supports multiple output formats. Some are for general use (xml, json) and some are even language specific. If you’re using PHP these are the most logical response writer formats:

  • xml
  • json
  • phps (serialized php)
  • php (php code to execute)

On top of that PHP offers multiple ways to parse XML. I’m benchmarking these options to determine the most efficient decoding to implement in the next major version of Solarium, but the results should be useful for any PHP Solr implementation.

Before I get to the results some info on how I tested.
Because this is only the first of several benchmarks I want to do the next few months I needed a good benchmarking tool. I couldn’t really find one that suits, so I’ve created a tool myself. It’s inspired by PHPUnit, but instead of test-cases you write benchmark-cases. It includes concepts like annotation and dataproviders. If you know PHPunit you will probably quickly understand this example:

class SolrParserBenchmark extends Phperf\Benchmark
{
 
    /**
     * @return array
     */
    public function solrJsonDataProvider()
    {
        return array(
            'small-results' => array(file_get_contents(__DIR__ . '/data/results.json')),
            'big-results' => array(file_get_contents(__DIR__ . '/data/text-results.json')),
        );
    }
 
    /**
     * Json decode
     *
     * Test data is similar to Solr output with wt=json
     *
     * @dataprovider solrJsonDataProvider
     * @repeat 50
     *
     * @param string $data
     * @return string
     */
    public function benchmarkJsonDecode($data)
    {
        return json_decode($data);
    }
}

The tool is still very much a prototype, but I intend on improving it for use by others as soon as I find the time. The current code, including this Solr benchmark, can be found on GitHub for those interested.

Results

Each decoding method is tested for a small result (approx. 10KB) and a big result (approx. 800KB). The tests are repeated 50 times and the result is the average time.

View the results here

Conclusions

  • The differences between decoding methods are quite big, in percentages
  • The size of the result data has a big impact, json_decode is second fastest with a small dataset but slowest with a big set.
  • There is a clear winner for both small and big datasets, unserialize
  • While the differences in percentages are big, even the worst performer with the big dataset (bigger than most real world cases) only takes about 16 thousands of a second.

Based on these results the next Solarium version will probably use unserialize (phps response format).

The tests were done on a 2Ghz i7 MBP running PHP 5.3.8. As always with benchmarkts, don’t just trust my tests, but be sure to test on your own environment! Your results might vary…



PHP Data (computing)

Published at DZone with permission of Bas De Nooijer, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • Java String Templates Today
  • How To Use the Node Docker Official Image
  • Payments Architecture - An Introduction
  • Five IntelliJ Idea Plugins That Will Change the Way You Code

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: