Skip to content

perf: defer instantiation of Validation in Model#8087

Merged
kenjis merged 2 commits into
codeigniter4:4.5from
kenjis:perf-model-defer-validation
Oct 26, 2023
Merged

perf: defer instantiation of Validation in Model#8087
kenjis merged 2 commits into
codeigniter4:4.5from
kenjis:perf-model-defer-validation

Conversation

@kenjis

@kenjis kenjis commented Oct 24, 2023

Copy link
Copy Markdown
Member

Description
Closes #7935

  • defer instantiation of Validation in Model

Memory Usage:

before: 17392
 after:  7216
<?php

namespace App\Controllers;

use CodeIgniter\Model;

class Home extends BaseController
{
    public function index(): string
    {
        $before = memory_get_usage();
        $model = new Model();
        $after = memory_get_usage();

        return $after - $before;
    }
}

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis kenjis added refactor Pull requests that refactor code 4.5 labels Oct 24, 2023
Comment thread system/BaseModel.php Outdated
@kenjis kenjis force-pushed the perf-model-defer-validation branch from 20bee81 to e8536c3 Compare October 25, 2023 02:13

@MGatner MGatner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice

@kenjis kenjis merged commit bfd7719 into codeigniter4:4.5 Oct 26, 2023
@kenjis kenjis deleted the perf-model-defer-validation branch October 26, 2023 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Pull requests that refactor code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants