2

As a software developer, I often have variables or database entries where I store how long a process took, and I'm always struggling to find the right noun to express that in the variable name.

For example, a database query took 200 ms, or an application took 8 seconds to start, and I'm trying to name a variable that stores the length of this time span.

Most of the time I've been using "duration", like "QueryDuration" or "AppStartDuration", but it doesn't seem to have the right sound to me. It doesn't sound like how long something took, but rather how long something lasted (like the summer holidays or a contract). Maybe I'm wrong about that?

What's a good word for that? Time span? Length of time? Is duration fine? In German, we have "Dauer" which works pretty well, but I need to use English.

I wouldn't like to just use time either, because that's ambiguous about whether it's a time span or a point in time.

5
  • 4
    I’m voting to close this question because variable naming isn't really English. The names of variables in a computer language don't have to be in English at all. There is no sense in which any answer is "right". The correct form of a computer variable depends on the style rules you are following. "Time", "Duration", "Length" "Period" all are reasonable and correct.
    – James K
    Aug 5, 2022 at 11:01
  • You might want to refer to the execution time or delay (the amount of time between the procedure being initiated and completed). Aug 5, 2022 at 11:46
  • I think ignoring the context of the question is poor advice in general. The answer to many questions depends on the context. Of the various synonyms for "duration" (that a dictionary will tell you) the best one will depend on the context in which it will be used. The only context given is "variable name"
    – James K
    Aug 5, 2022 at 12:34
  • 2
    @JamesK: I mentioned the context of the question exactly because it may be helpful in understanding the background of the question, but it was of course a question about English vocabulary, not about naming variables. I'm not seeking for concrete advice on how to name my variables, I'm looking for a good term. The question has been answered already -- my understandig of the word "duration" semms to have been wrong. That's exactly what I wanted to know.
    – HalvarF
    Aug 5, 2022 at 13:17
  • @JamesK The style of variable naming that OP is using is most definitely English (or Spanish, Russian, Japanese...). Variable names in this format are usually syntactically valid noun phrases, like startupTime, heightInMeters, or parent. If we were discussing the pros and cons of Hungarian notation (e.g. tStart, m_dy, or nodeParent), I would agree it should be off-topic. Aug 8, 2022 at 12:55

1 Answer 1

5

Duration has the technically correct meaning and will not be misinterpreted. It reports the length of the time interval in which a condition was true; in this case, the condition is that the operation is being performed.

If you want to focus on the cost of the operation, it is a little bit harder. We have lots of words for how much money was expended, like disbursement, outlay, cost, but not so many for how time was expended. You could use time spent if the cost in time is a really important concept.

  • Time spent in query: 12 µs
  • Time spent to start up: 8 s

There are technical terms like dwell and delay for time spent while nothing changes or happens, but your examples suggest that you want a term for time spent while an operation is being performed.

4
  • Thanks a lot! "Time spent" is a very good idea, and it was good to know that I misunderstood "duration" in that respect.
    – HalvarF
    Aug 5, 2022 at 13:20
  • 5
    elapsed is the word for time that's been expended.
    – amalloy
    Aug 5, 2022 at 16:53
  • But elapsed is an adjective, not a noun. You can’t say “the elapsed”, you have to say “the elapsed time”
    – djs
    Aug 6, 2022 at 4:18
  • @amalloy: thank you. "Elapsed" was also mentioned in a secoond answer that has disappeared.
    – HalvarF
    Aug 8, 2022 at 20:07

Not the answer you're looking for? Browse other questions tagged .