Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
Explained what I tried
Source Link
I Like to Code
  • 7.4k
  • 13
  • 42
  • 50

In MATLAB, there are a pair of functions tic and toc which can be used to start and stop a stopwatch timer. An example taken from link:

tic
A = rand(12000, 4400);
B = rand(12000, 4400);
toc
C = A'.*B';
toc

I am aware that there is a macro @time in Julia that has similar functionality.

julia> @time [sin(cos(i)) for i in 1:100000];
elapsed time: 0.00721026 seconds (800048 bytes allocated)

Is there a set of similar functions in Julia? The @time macro works well for timing statements that can be written in one or two lines. For longer portions of code, I would prefer to use tic-toc functions.

What I tried

When I googled "julia stopwatch", I found one useful link and four unrelated links.

  1. Introducing Julia/Metaprogramming - Wikibooks, open ... Meta-programming is when you write Julia code to process and modify Julia code. ... The @time macro inserts a "start the stopwatch" command at the beginning ...
  2. Our Invisible Stopwatch promo - YouTube Video for julia stopwatch
  3. Julia Larson on Twitter: "This #Mac OSX timer/stopwatch is ...
  4. Timing episodes of The French Chef with a stopwatch
  5. julia griffith | Oiselle Running Apparel for Women

I don't know why I hadn't thought of just trying tic() and toc().

In MATLAB, there are a pair of functions tic and toc which can be used to start and stop a stopwatch timer. An example taken from link:

tic
A = rand(12000, 4400);
B = rand(12000, 4400);
toc
C = A'.*B';
toc

I am aware that there is a macro @time in Julia that has similar functionality.

julia> @time [sin(cos(i)) for i in 1:100000];
elapsed time: 0.00721026 seconds (800048 bytes allocated)

Is there a set of similar functions in Julia? The @time macro works well for timing statements that can be written in one or two lines. For longer portions of code, I would prefer to use tic-toc functions.

In MATLAB, there are a pair of functions tic and toc which can be used to start and stop a stopwatch timer. An example taken from link:

tic
A = rand(12000, 4400);
B = rand(12000, 4400);
toc
C = A'.*B';
toc

I am aware that there is a macro @time in Julia that has similar functionality.

julia> @time [sin(cos(i)) for i in 1:100000];
elapsed time: 0.00721026 seconds (800048 bytes allocated)

Is there a set of similar functions in Julia? The @time macro works well for timing statements that can be written in one or two lines. For longer portions of code, I would prefer to use tic-toc functions.

What I tried

When I googled "julia stopwatch", I found one useful link and four unrelated links.

  1. Introducing Julia/Metaprogramming - Wikibooks, open ... Meta-programming is when you write Julia code to process and modify Julia code. ... The @time macro inserts a "start the stopwatch" command at the beginning ...
  2. Our Invisible Stopwatch promo - YouTube Video for julia stopwatch
  3. Julia Larson on Twitter: "This #Mac OSX timer/stopwatch is ...
  4. Timing episodes of The French Chef with a stopwatch
  5. julia griffith | Oiselle Running Apparel for Women

I don't know why I hadn't thought of just trying tic() and toc().

Source Link
I Like to Code
  • 7.4k
  • 13
  • 42
  • 50

Stopwatch function in Julia

In MATLAB, there are a pair of functions tic and toc which can be used to start and stop a stopwatch timer. An example taken from link:

tic
A = rand(12000, 4400);
B = rand(12000, 4400);
toc
C = A'.*B';
toc

I am aware that there is a macro @time in Julia that has similar functionality.

julia> @time [sin(cos(i)) for i in 1:100000];
elapsed time: 0.00721026 seconds (800048 bytes allocated)

Is there a set of similar functions in Julia? The @time macro works well for timing statements that can be written in one or two lines. For longer portions of code, I would prefer to use tic-toc functions.