Skip to content
Myr

timing: rename time_end() -> time_finish()

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Add time_end() that, just like time_begin(), returns a malloc:ed timespec * time_finish() now take an optional 'stop' argument (i.e. from time_end()). If NULL, time_finish() itself will calculate the stop time itself This allows us to separate the stop call from logging it.

authored by Daniel Eklöf · committed by Daniel Eklöf · parent 0221d35 · Browse files · 5 files+62 added−47 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+62 added−47 removed

  • other:+62 added−47 removed

5 files+62 added−47 removed

modified:main.c+21 added-31 removed
65 unmodified lines
66 int dmenu_abort_fd;6768 struct {69 struct {70 struct timeval start;71 struct timeval stop;72 struct timeval diff;70 struct timespec *start;71 struct timespec *stop;72 } apps;73 struct {75 struct timeval start;76 struct timeval stop;77 struct timeval diff;74 struct timespec *start;75 struct timespec *stop;76 } icons_theme;77 struct {80 struct timeval start;81 struct timeval stop;82 struct timeval diff;78 struct timespec *start;79 struct timespec *stop;80 } icons;81 } timing;82};83
503 unmodified lines
587 free(xdg_current_desktop);588 }589 }590591 ctx->timing.apps.start = time_begin();592593 if (dmenu_enabled) {594 if (!conf->prompt_only) {595 dmenu_load_entries(596 apps, dmenu_delim, dmenu_with_nth_format, dmenu_nth_delim,597 ctx->event_fd, ctx->dmenu_abort_fd);598 read_cache(cache_path, apps, true);599 }600 } else {602 gettimeofday(&ctx->timing.apps.start, NULL);601 xdg_find_programs(terminal, actions_enabled, filter_desktop, &desktops, apps);602 if (list_exec_in_path)603 path_find_programs(apps);604 read_cache(cache_path, apps, false);607 gettimeofday(&ctx->timing.apps.stop, NULL);608 timersub(&ctx->timing.apps.stop, &ctx->timing.apps.start, &ctx->timing.apps.diff);605 }606 tll_free_and_free(desktops, free);607608 ctx->timing.apps.stop = time_end();609610 int r = send_event(ctx->event_fd, EVENT_APPS_ALL_LOADED);611 if (r != 0)612 return r;613614 if (icons_enabled) {617 gettimeofday(&ctx->timing.icons_theme.start, NULL);615 ctx->timing.icons_theme.start = time_begin();616 icon_theme_list_t icon_themes = icon_load_theme(icon_theme, !dmenu_enabled);617 if (tll_length(icon_themes) > 0)618 LOG_INFO("theme: %s", tll_front(icon_themes).name);619 else620 LOG_WARN("%s: icon theme not found", icon_theme);623 gettimeofday(&ctx->timing.icons_theme.stop, NULL);624 timersub(&ctx->timing.icons_theme.stop, &ctx->timing.icons_theme.start, &ctx->timing.icons_theme.diff);621 ctx->timing.icons_theme.stop = time_end();622626 gettimeofday(&ctx->timing.icons.start, NULL);623 ctx->timing.icons.start = time_begin();624 mtx_lock(ctx->icon_lock);625 {626 *ctx->themes = icon_themes;627 if (ctx->icon_size > 0) {
5 unmodified lines
633 }634 }635 }636 mtx_unlock(ctx->icon_lock);640 gettimeofday(&ctx->timing.icons.stop, NULL);641 timersub(&ctx->timing.icons.stop, &ctx->timing.icons.start, &ctx->timing.icons.diff);637 ctx->timing.icons.stop = time_end();638639 r = send_event(ctx->event_fd, EVENT_ICONS_LOADED);640 if (r != 0)641 return r;
14 unmodified lines
656657 switch (event) {658 case EVENT_APPS_SOME_LOADED:659 case EVENT_APPS_ALL_LOADED: {664 if (event == EVENT_APPS_ALL_LOADED && conf->print_timing_info) {665 LOG_WARN("apps loaded in %llus %lluµs",666 (unsigned long long)ctx->timing.apps.diff.tv_sec,667 (unsigned long long)ctx->timing.apps.diff.tv_usec);660 if (event == EVENT_APPS_ALL_LOADED) {661 time_finish(662 ctx->timing.apps.start, ctx->timing.apps.stop, "apps loaded");663 }664 /* Update matches list, then refresh the GUI */665 matches_set_applications(matches, apps);666
57 unmodified lines
724 }725726 case EVENT_ICONS_LOADED:727 /* Just need to refresh the GUI */733 if (conf->print_timing_info) {734 LOG_WARN("icon themes loaded in %llus %lluµs",735 (unsigned long long)ctx->timing.icons_theme.diff.tv_sec,736 (unsigned long long)ctx->timing.icons_theme.diff.tv_usec);737 LOG_WARN("icon paths resolved in %llus %lluµs",738 (unsigned long long)ctx->timing.icons.diff.tv_sec,739 (unsigned long long)ctx->timing.icons.diff.tv_usec);740 }728 time_finish(ctx->timing.icons_theme.start, ctx->timing.icons_theme.stop,729 "icon themes loaded");730 time_finish(ctx->timing.icons.start, ctx->timing.icons.stop,731 "icon paths resolved");732 matches_icons_loaded(matches);733 break;734735 default:
1513 unmodified lines
22492250 if (!fdm_add(fdm, event_pipe[0], EPOLLIN, &fdm_apps_populated, &ctx))2251 goto out;22522262 gettimeofday(&ctx.timing.apps.start, NULL);2253 if (thrd_create(&app_thread_id, &populate_apps, &ctx) != thrd_success) {2254 LOG_ERR("failed to create thread");2255 goto out;2256 }
93 unmodified lines
modified:render.c+4 added-4 removed
1183 unmodified lines
1184 free(start_load);1185 return;1186 }11871188 time_end(start_load, "%s loaded", icon->path);1188 time_finish(start_load, NULL, "%s loaded", icon->path);1189 LOG_DBG("%s", icon->path);1190 }11911192 struct timespec *render_start = time_begin();
5 unmodified lines
1198#elif defined(FUZZEL_ENABLE_SVG_RESVG)1199 render_svg_resvg(icon, x, y, size, pix, cairo, gamma_correct);1200#endif12011202 time_end(render_start, "%s rendered", icon->path);1202 time_finish(render_start, NULL, "%s rendered", icon->path);1203}12041205#if defined(FUZZEL_ENABLE_PNG_LIBPNG)1206static void
171 unmodified lines
1378 free(start_load);1379 return;1380 }13811382 time_end(start_load, "%s loaded", icon->path);1382 time_finish(start_load, NULL, "%s loaded", icon->path);1383 LOG_DBG("%s", icon->path);1384 }13851386 struct timespec *start_render = time_begin();
1 unmodified line
1388#if defined(FUZZEL_ENABLE_PNG_LIBPNG)1389 render_png_libpng(icon, x, y, size, pix, cairo, scaling_filter);1390#endif13911392 time_end(start_render, "%s rendered", icon->path);1392 time_finish(start_render, NULL, "%s rendered", icon->path);1393}13941395static int1396first_row_y(const struct render *render)
582 unmodified lines
modified:timing.c+32 added-9 removed
65 unmodified lines
6667 LOG_WARN("%s: %lds %ldµs since bootup", msg, diff.tv_sec, diff.tv_nsec / 1000);68}6970struct timespec *71time_begin(void)70static struct timespec *71time_stamp(void)72{73 if (!enabled)74 return NULL;75
4 unmodified lines
80 clock_gettime(CLOCK_MONOTONIC, ret);81 return ret;82}8384void85time_end(struct timespec *start, const char *fmt, ...)84struct timespec *85time_begin(void)86{87 if (start == NULL)88 return;87 return time_stamp();88}8990struct timespec *91time_end(void)92{93 return time_stamp();94}9596void97time_finish(struct timespec *start, struct timespec *stop, const char *fmt, ...)98{99 if (!enabled) {100 free(start);101 free(stop);102 return;103 }10495 struct timespec stop;96 clock_gettime(CLOCK_MONOTONIC, &stop);105 if (start == NULL)106 return;107108 if (stop == NULL) {109 stop = malloc(sizeof(*stop));110111 if (stop == NULL) {112 free(start);113 free(stop);114 return;115 }116117 clock_gettime(CLOCK_MONOTONIC, stop);118 }119120 struct timespec diff;99 timespec_sub(&stop, start, &diff);121 timespec_sub(stop, start, &diff);122123 va_list va1, va2;124 va_start(va1, fmt);125 va_copy(va2, va1);
7 unmodified lines
133134 LOG_WARN("%s in %lds %ldµs", msg, diff.tv_sec, diff.tv_nsec / 1000);135136 free(start);137 free(stop);138}
modified:timing.h+2 added-1 removed
6 unmodified lines
78void time_since_boot(const char *fmt, ...) __attribute__((format(printf, 1, 2)));910struct timespec *time_begin(void);11void time_end(struct timespec *start, const char *fmt, ...) __attribute__((format(printf, 2, 3)));11struct timespec *time_end(void);12void time_finish(struct timespec *start, struct timespec *stop, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
modified:wayland.c+3 added-2 removed
2595 unmodified lines
2596 /* No pending frames - render immediately */2597 assert(!wayl->need_refresh);2598 commit_buffer(wayl, buf);2599done:26002600 time_end(2601 start_frame, "%sframe rendered",2601 time_finish(2602 start_frame, NULL, "%sframe rendered",2603 wayl->render_first_frame_transparent ? "transparent " : "");2604}26052606void
552 unmodified lines