Using Time In Your Programs

Updated: January 25, 2022
No Credit Card Required
ClaimYour
FreeTrialClass

Transcript

Time can be a friend. But when you have a lot of things to do during the course of a day, time is often an enemy. When planning your day, you have to set aside enough time for each important activity, school exams, dinner, chores, and homework all require some time. You must also ensure that you leave enough time between activities, so you have enough time to go from one activity to the next without getting too red in the face.

So what is time anyway? Well, time is kind of weird and hard to explain. It's the continuous passing of events from past to present to future. In other words, it's an infinite succession of moments during which events occur. It is measured in seconds, minutes, hours, days and years. Beyond that, time is a pretty sticky concept. It even seems to slow down or speed up based on whether an activity is boring or fun. It also often seems to speed up during exam period, we humans use time to orient ourselves in space and time. We use it to synchronize our lives with the spinning of the earth on its axis.

Time is used as a reference to organize our days and nights. The time between any two events, whether it's a second a day, or a year is called a duration. Now, you might think that time only matters to people. But time is actually very important to computers to computers and robots need to be told when to do something, and for how long otherwise things would get very chaotic.

When computers check the time, this is called synchronization. Time is of utmost importance to the flow and order of operations. From sitting down to taking a left turn in a vehicle. It all depends on time. So in programming time is used to tell the computer what to do at a specific moment. It is also used to tell the computer when to stop, or how long it should execute a code before stopping.

Each computer has a clock inside it and the processor looks at it every time it is executing an instruction. It is how computers are able to synchronize what you tell them to do with time, the processors clock speed is very important. It measures how many clock cycles a processor can perform per second, the number is usually huge, billions of clock cycles per second. The more clock cycles per second a processor has, the faster we can say it is it means it can do more things in a specific amount of time.

Time and the proper application of it plays a huge role in starting and ending program events. Idle time and the duration of the execution of specific code activities are all bound up in time too. It's also a measure for the performance of a computer's processor. Just like computers. Some people seem to have a sort of inbuilt clock to well when it comes to knowing when it's time for dinner.

Loading...