Code Monkey home page Code Monkey logo

Comments (11)

robbieaverill avatar robbieaverill commented on June 15, 2024

It's worth noting that this change would be required to get this module into the CWP 2.0 recipe, since at the moment it conflicts with 2 or 3 other SilverStripe modules with also proxy the database.

from silverstripe-debugbar.

robbieaverill avatar robbieaverill commented on June 15, 2024

I think we need to get this done before this module can be tagged as stable for SilverStripe 4. What do you think about this @lekoala?

from silverstripe-debugbar.

lekoala avatar lekoala commented on June 15, 2024

it makes sense to be able to simply add an extension to the database instead of make a full proxy.

i'm a bit sad however that the extension points are not included in the core itself and the we need to rely on a module that dynamically attach behaviours to methods, too much magic for me

what do you think @tractorcow ? is the db proxy really the way the SilverStripe team wants to go? why not simply add a couple of extension points in the database class itself?

from silverstripe-debugbar.

tractorcow avatar tractorcow commented on June 15, 2024

i'm a bit sad however that the extension points are not included in the core itself and the we need to rely on a module that dynamically attach behaviours to methods, too much magic for me

Yes I agree. Maybe 4.2 we could do that and not need the proxy. It just never made it in, in time.

from silverstripe-debugbar.

lekoala avatar lekoala commented on June 15, 2024

ok, meanwhile we can actually do both: if the module is installed, use it, otherwise keep the current behaviour.

from silverstripe-debugbar.

lekoala avatar lekoala commented on June 15, 2024

hey @tractorcow I had a look at the proxy db module. Do you see a way to get time before AND after the query? as far as I can tell, the middleware is executed before the last callback that will actually execute the query, so there is no easy way to get the time needed to execute the query.

In ProxiedBehaviour::invoke could you add another loop with the result returned by the last $next(...$args) ?

Or if you have any other idea of course... I still believe it would be a lot easier to add to extension point in Database::benchmarkQuery method : $this->extend('onBeforeQuery', ...) and $this->extend('onAfterQuery', ...).

from silverstripe-debugbar.

robbieaverill avatar robbieaverill commented on June 15, 2024

from silverstripe-debugbar.

lekoala avatar lekoala commented on June 15, 2024

Well, I can call next, but it's only going to call the next middleware, not actually execute the query.

Something like this

        // Get time and memory for the request
        $startTime = microtime(true);
        $startMemory = memory_get_usage(true);

        // Execute all middleware
        $result = $next(...$args);

        $endTime = round(microtime(true) - $startTime, 4);
        $endMemory = memory_get_usage(true);

Doesn't work at all, but I think that's to be expected because from what I've seen, it's not a double pass middleware, but I may be wrong. Collecting the queries is easy enough, it's just profiling them that is difficult.

from silverstripe-debugbar.

tractorcow avatar tractorcow commented on June 15, 2024

@lekoala the last item in the middleware is execution of the query. Your last code comment should work.

If it's not I've done something wrong in the module.

from silverstripe-debugbar.

lekoala avatar lekoala commented on June 15, 2024

Indeed! Too much callback mystery in my mind...

Implemented in b56a8ed

from silverstripe-debugbar.

lekoala avatar lekoala commented on June 15, 2024

Just updated the test suite as well, but it is failing for lots of strange reason on my computer (no config manifests and nest/unest issues) so it's probably not thoroughly tested

from silverstripe-debugbar.

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.