Does anyone know how to solve the following: A programming course wants to measure how much time it takes to solve the exercises. I use Ubuntu 19.04. Let's say I write the code by using Visual Studio Codium and do not use it any other projects on the week. How can I measure how long the editor is running on given week?

  • 2
    The editor could be open while the user could be doing something else. In other words how do you differentiate the user thinking about the code and the user off for a cup of coffee? You can't even use the criterion that the editor should be in focus, because the user could be using StackOverflow... or chilling on BuzzFeed. – xenoid Aug 26 '19 at 8:36
  • Time at keyboard is not the same as time to solve problem. I solve most of my problems, when walking, or in the toilet. Tests of writing small programs, don't measure this. Time to solve is also not a good measure of learning. – ctrl-alt-delor Aug 26 '19 at 9:05
  • @xenoid I don't use StackOverflow when coding as there is really seldom copyright or license that allows to use code in my projects. – juniorprogrammer Aug 26 '19 at 9:10
  • 1
    All the code in SO is CC-BY-SA (read the rules). Using StackOverflow is not about cutting&pasting code, it is about solving your problems. – xenoid Aug 26 '19 at 9:37

One method is to use the acct accounting utilities.

From the debian package description:

$ apt-cache show acct
Package: acct
Version: 6.6.4-2
Installed-Size: 341
Maintainer: Debian Security Tools <team+pkg-security@tracker.debian.org>
Architecture: amd64
Depends: libc6 (>= 2.14), lsb-base
Description-en: GNU Accounting utilities for process and login accounting
 GNU Accounting Utilities is a set of utilities which reports and summarizes
 data about user connect times and process execution statistics.
 "Login accounting" provides summaries of system resource usage based on connect
 time, and "process accounting" provides summaries based on the commands
 executed on the system.
 The 'last' command is provided by the sysvinit package and not included here.

Homepage: http://www.gnu.org/software/acct/

This package includes a reporting tool called sa. You may have to write scripts in awk or perl or something to post-process sa's output into the exact form you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.