Project

General

Profile

Actions

Bug #13397

closed

ls calls time() many more times than necessary

Added by Peter Tribble 9 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
cmd - userland programs
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

Investigating why my machine was reporting such a high number of sycalls, I stumbled across this in ls.c

rep->lat.tv_sec = time(NULL);
rep->lct.tv_sec = time(NULL);
rep->lmt.tv_sec = time(NULL);

For every file, ls calls time() 3 times, and only does so to ensure the values exist - the actual time here is arbitrary, and would normally be replaced by the times from the stat structure gotten from the file.

Removing those time() calls would make ls quicker, and reduce system load.


Files

13397.sh (2.35 KB) 13397.sh Peter Tribble, 2021-06-08 08:20 PM
Actions

Also available in: Atom PDF