in in English

How to not waste time while your scripts are running

You might have short delays in your work, ranging from 20 seconds to more than 10 minutes. This could happen, for example, when you’re running or compiling code (building a large project), running tests or, as in my case, when running SQL database queries, R scripts, or MATLAB simulations.

I recently noticed that these small delays sum to a significant amount of time wasted in my day – on each occasion, I might waste only 2 minutes, but since I have to run queries and scripts anywhere from 10 to 50 times a day, this is an actual problem hindering my productivity. ZeroTurnaround has even built a successful business around reducing this waste of developer time.

The problem is not so much that I don’t have anything to do in these 2 minutes — for example, I could read e-mail in that time — but that I don’t want to switch tasks very often. Rapid task switching imposes significant overhead costs in time and cognitive capacity, and multitasking (which consists mainly of frequently switching between tasks) is known to make you less efficient (including specifically in technology jobs).


Obviously, I tried to find answers online. While there were no relevant answers when googling “what to do when query is running”, I found two hits to “what to do when code is compiling” on StackExchange, four answers on Quora, and obviously a lot of references to the relevant xkcd strip.

I also asked a couple of colleagues at Skype and my brother, who all do data-related work and face a similar problem. Here’s a brief summary of what people are suggesting, in (my estimated) order of usefulness. Most answers focus on either finding ways to reduce the length of unproductive time, or making better use of the time you’d otherwise waste.

Things to do during the waiting period

Some of these still include task-switching, but there doesn’t seem to be a good way to avoid it.

  1. Comment or document your code. Update and clarify your task on the issue tracker: progress, description, chosen approach.
  2. Think about your task. What will you need to do next, and how will you do it?
  3. Rest your eyes. Look at something distant for a while to reduce the strain on your eyes.
  4. Meditate. Mindfulness meditation might help you keep your focus while having a relaxing short-term effect at the same time. Read about longer-term effects here.
  5. Exercise or stretch. Do push-ups or some other form of quick exercise. Wave your arms, stretch your back, etc.
  6. Reply to e-mail or read work-related chats.
  7. Do small work tasks not requiring a lot of focus. For example, a data scientist might use this time to plot graphs or do simple work in spreadsheets.
  8. Do small non-work tasks. Organise your desk, adjust your chair, clean your file system etc. I’ve found that I usually quickly run out of tasks of this kind.
  9. Decompress. Look for interesting StackOverflow questions. Skim the news. Read your RSS feed. Solve a Rubik’s cube. Juggle balls. Watch a “semi-lame movie that is barely enough to keep your interest“. Beware – it’s very easy to fall into procrastination.

Sources here, here, herehere,

Reduce waiting time

This is a pretty obvious idea, but it might not be obvious how much you could benefit from this. If you can shave 30 seconds off something you do 20 times a day, 180 days a year, you will save 30 productive hours in a year. Here are some things to try:

  1. Set a timer for n minutes (where n is a bit less than your usual waiting time, but I recommend about 5 minutes), take a sheet of paper and try to brainstorm ways you can reduce the waiting time in your situtation. Do it right now (or create a todo-item for it – you might be surprised how well this works.
  2. Decrease the turnaround time by writing more efficient queries or code, or spend some time learning how.
  3. Measure system performance to find the bottleneck, and try to optimise that part of the system.
  4. Refactor your code into smaller components so you don’t need to compile/run so often. [source]
  5. Document the time wasted on waiting, do some cost calculation and see if you can use it to justify a faster system (hardware upgrade, migration to a new system etc) to your manager. [source]

You can do any of these things while waiting, but I’d recommend allocating some distinct time and focusing for a better result.



Lisa kommentaar


This site uses Akismet to reduce spam. Learn how your comment data is processed.