From 68c2b29caf3fadeaf49d296231ad48ca32ed645d Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Thu, 13 Apr 2017 22:26:51 +0200 Subject: [PATCH] CMovieBrowser: try to reduce effort for vizualized scan For comparings I added a benchmark with log output. --- src/gui/moviebrowser/mb.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gui/moviebrowser/mb.cpp b/src/gui/moviebrowser/mb.cpp index f55f994ab..f85cc093e 100644 --- a/src/gui/moviebrowser/mb.cpp +++ b/src/gui/moviebrowser/mb.cpp @@ -2876,7 +2876,8 @@ bool CMovieBrowser::loadTsFileNamesFromDir(const std::string & dirname) CFileList flist; if (readDir(dirname, &flist) == true) { - for (size_t i = 0; i < flist.size(); i++) + size_t count = flist.size(); + for (size_t i = 0; i < count; i++) { if (S_ISDIR(flist[i].Mode)) { if (m_settings.ts_only || !CFileBrowser::checkBD(flist[i])) { @@ -2887,7 +2888,8 @@ bool CMovieBrowser::loadTsFileNamesFromDir(const std::string & dirname) } else { result |= addFile(flist[i], dirItNr); } - OnLocalProgress(i, flist.size(), dirname ); + if (result) + OnLocalProgress(i, count, dirname ); } //result = true; } @@ -3126,6 +3128,9 @@ void CMovieBrowser::loadMovies(bool doRefresh) { TRACE("[mb] loadMovies: \n"); + struct timeval t1, t2; + gettimeofday(&t1, NULL); + CProgressWindow loadBox((show_mode == MB_SHOW_YT) ? LOCALE_MOVIEPLAYER_YTPLAYBACK : LOCALE_MOVIEBROWSER_SCAN_FOR_MOVIES, CCW_PERCENT 50, CCW_PERCENT 10, NULL, show_mode == MB_SHOW_YT ? &ytparser.OnProgress : &OnLocalProgress, &OnGlobalProgress); loadBox.enableShadow(); loadBox.paint(); @@ -3141,6 +3146,11 @@ void CMovieBrowser::loadMovies(bool doRefresh) } m_file_info_stale = false; + gettimeofday(&t2, NULL); + uint64_t duration = ((t2.tv_sec * 1000000ULL + t2.tv_usec) - (t1.tv_sec * 1000000ULL + t1.tv_usec)) / 1000ULL; + if (duration) + fprintf(stderr, "\033[33m[CMovieBrowser] %s: %" PRIu64 " ms to scan movies \033[0m\n",__func__, duration); + loadBox.hide(); if (doRefresh)