Skip to content

Commit

Permalink
perf: Cache Bench and App instantiation
Browse files Browse the repository at this point in the history
  • Loading branch information
gavindsouza committed Nov 17, 2021
1 parent ac07d8d commit cd1f526
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bench/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# imports - standard imports
import functools
import json
import logging
import os
Expand All @@ -7,6 +8,7 @@
import subprocess
import sys
import typing
from datetime import date

# imports - third party imports
import click
Expand Down Expand Up @@ -127,7 +129,7 @@ def get_http_url(self):
def get_ssh_url(self):
return f"git@{self.remote_server}:{self.org}/{self.repo}.git"


@functools.lru_cache(maxsize=None)
class App(AppMeta):
def __init__(
self, name: str, branch: str = None, bench: "Bench" = None, *args, **kwargs
Expand Down
3 changes: 3 additions & 0 deletions bench/bench.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# imports - standard imports
import functools
import os
import shutil
import sys
Expand Down Expand Up @@ -45,6 +47,7 @@ def validate_app_uninstall(self, app):
validate_app_installed_on_sites(app, bench_path=self.name)


@functools.lru_cache(maxsize=None)
class Bench(Base, Validator):
def __init__(self, path):
self.name = path
Expand Down
1 change: 1 addition & 0 deletions bench/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
)
from bench.utils.bench import get_env_cmd

fancy = True
from_command_line = False
bench.LOG_BUFFER = []
change_uid_msg = "You should not run this command as root"
Expand Down

0 comments on commit cd1f526

Please sign in to comment.