Q:

What is the difference between  and ?

For measuring execution time of a function, I can use both. But what is the difference between using <chrono> and <ctime>? Should I prefer one instead of another? 

A:

ctime is a C-style header, it's old, not type safe and not as accurate as chrono. chrono is the preferred option in C++; it's a contemporary C++ header, it's type safe, as accurate as our hardware allows, it has extended functionality, and, more importantly, it follows C++ (rather than C) logic so that certain things will be more natural/expressive with it and so that we may expect it to be aware of many contemporary language features (threads, exceptions, etc) - we cannot make the same assumptions for ctime. 
That said, there are still several use-cases for ctime (or even time.h), e.g. when we need to talk with some C API or when we rely on old code-bases or when we use some library which follows a different kind of logic. C++ is designed to be pragmatic and not to be "pure" in any respect; this is why ctime and all sorts of antiquated headers, syntaxes and language features are still there even if programers are discouraged from using them. 

A:

ctime is old school. Its only use now is as a crap solution to getting dates from time points (since c++ doesn't have an adequate standard datetime library). For general time needs, use chrono. If you need to turn a system_clock::time_point into a date/time, use ctime.

