GithubHelp home page GithubHelp logo

Comments (4)

adriannuta avatar adriannuta commented on July 28, 2024

The class instance can be passed instead of the class name (like 'connectionStrategy' => new \Manticoresearch\Connection\Strategy\StaticRoundRobin()).

Removing the class_exists or disabling the autoload I don't think are good ideas. Instead at

if (class_exists($strategyName)) {

it might make sense to test if the class name starts with Manticoresearch\ (like 0 === strncmp($className, 'Manticoresearch\\', 16))

from manticoresearch-php.

githubmanticore avatar githubmanticore commented on July 28, 2024

➤ Nick Sergeev commented:

I've run both variants, but actually haven't observed a noticeable difference in performance.

Here is my test script test_time.php

<?php 
 
require_once  __DIR__ . '/vendor/autoload.php'; 
$config_connections = [ 
    [ 
        'host' => 'localhost', 
        'port' => '9308', 
    ], 
]; 
$client = new \Manticoresearch\Client([ 
    'connections' => $config_connections, 
    'connectionStrategy' => 'StaticRoundRobin',  // variant 1 
    //'connectionStrategy' => \Manticoresearch\Connection\Strategy\StaticRoundRobin::class, // variant 2 
    'retries' => 3 
]); 
 
?> 

And here is an example of the performance times obtained with time php test_time.php for the variants 1 and 2, respectively:

real	0m0,042s 
user	0m0,031s 
sys	0m0,009s 

and

real	0m0,042s 
user	0m0,025s 
sys	0m0,009s 

from manticoresearch-php.

markomilivojevic avatar markomilivojevic commented on July 28, 2024

The difference cannot be noticed with very few php classes in a project, but when you have thousands of classes it is noticeable. It rebuilds autoload for all classes in a project.

from manticoresearch-php.

githubmanticore avatar githubmanticore commented on July 28, 2024

➤ Nick Sergeev commented:

Ok, as it was proposed above, we updated the client to skip the class_exists check if the path to a strategy class starts with Manticoresearch\

from manticoresearch-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.