Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various improvements for startup performance #126

Merged
merged 26 commits into from
Nov 23, 2019
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
549bf3f
Use fastentrypoints to speed-up startup
karlch Nov 18, 2019
29a7e91
Simplify logic checking for existing keybindings
karlch Nov 18, 2019
5a190dd
Move logic from commands.register to constructor
karlch Nov 18, 2019
e49a02f
Do not always log version information
karlch Nov 18, 2019
b895373
Move debugging utilities to own module
karlch Nov 18, 2019
9b2e745
Correctly use xdg join for trash directories
karlch Nov 19, 2019
aeb91f7
Use QStackedWidget for image / thumbnail
karlch Nov 20, 2019
cc09038
Refactor api.modes for emitting first_entered
karlch Nov 20, 2019
cdc9148
Refactor manipulate for lazy initialization
karlch Nov 20, 2019
3cfbf36
Fix crash when transforming without valid pixmap
karlch Nov 20, 2019
a19b5ed
Create commandline in gui.bar
karlch Nov 20, 2019
7de6e5d
Fix end2end tests for mode first_entered
karlch Nov 20, 2019
55b8444
Remove use of datetime module
karlch Nov 20, 2019
449b005
Remove unused logging.handlers import
karlch Nov 20, 2019
8aee388
Initialize completion models on commmand enter
karlch Nov 20, 2019
5c8330c
Add function to run shell command in QProcess
karlch Nov 21, 2019
b709d64
Use QProcess for git version information
karlch Nov 21, 2019
6f487ba
Write pixmaps on quit in serial
karlch Nov 21, 2019
c726aa4
Use QProcess implementation for external commands
karlch Nov 21, 2019
af75559
Make logging lazier
karlch Nov 21, 2019
78330f9
Fix mypy
karlch Nov 21, 2019
f717738
Add contains_any utility method
karlch Nov 23, 2019
aff26ae
Add function to escape for glob
karlch Nov 23, 2019
829cf4a
Improve wildcard handling for paths and !external
karlch Nov 23, 2019
49549d6
Fix mypy
karlch Nov 23, 2019
43bb5e6
Update documentation for :spawn
karlch Nov 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove use of datetime module
This can easily be done using QDateTime and saves an import :)
karlch committed Nov 20, 2019
commit 55b8444141dcaf721fa2187da2fb787bb83d36f2
7 changes: 3 additions & 4 deletions vimiv/api/_mark.py
Original file line number Diff line number Diff line change
@@ -9,10 +9,9 @@

import os
import shutil
from datetime import datetime
from typing import Any, Callable, List, cast

from PyQt5.QtCore import QObject, pyqtSignal, QFileSystemWatcher
from PyQt5.QtCore import QObject, pyqtSignal, QFileSystemWatcher, QDateTime

from vimiv.config import styles
from vimiv.utils import files, xdg, remove_prefix, wrap_style_span, slot, log
@@ -333,8 +332,8 @@ def path(name: str) -> str:
def _write_header(self) -> None:
"""Write header to a new tag file."""
self._write_comment("vimiv tag file")
now = datetime.now()
formatted_time = now.strftime("%Y-%m-%d %H:%M")
now = QDateTime.currentDateTime()
formatted_time = now.toString("yyyy-MM-dd HH:mm")
self._write_comment(f"created: {formatted_time}")

def _write_comment(self, comment: str) -> None:
6 changes: 3 additions & 3 deletions vimiv/api/_modules.py
Original file line number Diff line number Diff line change
@@ -10,11 +10,11 @@
corresponding objects.
"""

import datetime
import os
from contextlib import suppress
from typing import List

from PyQt5.QtCore import QDateTime
from PyQt5.QtGui import QGuiApplication, QClipboard

import vimiv
@@ -253,5 +253,5 @@ def modified() -> str:
mtime = os.path.getmtime(api.current_path())
except OSError:
return "N/A"
d = datetime.datetime.fromtimestamp(mtime)
return d.strftime("%y-%m-%d %H:%M")
date_time = QDateTime.fromSecsSinceEpoch(int(mtime))
return date_time.toString("yyyy-MM-dd HH:mm")
6 changes: 3 additions & 3 deletions vimiv/utils/debug.py
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@

import cProfile
import functools
import time
from contextlib import contextmanager
from datetime import datetime
from pstats import Stats
from typing import Any, Iterator

@@ -23,9 +23,9 @@ def timed(function: FuncT) -> FuncT:
@functools.wraps(function)
def inner(*args: Any, **kwargs: Any) -> Any:
"""Wrap decorated function and add timing."""
start = datetime.now()
start = time.time()
return_value = function(*args, **kwargs)
elapsed_in_ms = (datetime.now() - start).total_seconds() * 1000
elapsed_in_ms = (time.time() - start) * 1000
log.info("%s: took %.3f ms", function.__qualname__, elapsed_in_ms)
return return_value