First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

asked 13 years ago

chaesloc2 gravatar image

Record output of timeit in variable

How can I record in a variable the amount of time taken by a function? I read somewhere that timeit is the good way to time stuff, but it seems to print its output instead of returning it.

click to hide/show revision 2
No.2 Revision

Record output of timeit in variable

How can I record in a variable the amount of time taken by a function? I read somewhere that timeit is the good way to time stuff, but it seems to print its output instead of returning it.it. If possible, I would prefer not to redirect streams or redefine print, etc.

click to hide/show revision 3
No.3 Revision

Record output of timeit in variable

How can I record in a variable the amount of time taken by a function? I read somewhere that timeit is the good way to time stuff, but it seems to print its output instead of returning it. it.

If possible, I would prefer not to redirect streams or redefine print, etc.

click to hide/show revision 4
No.4 Revision

Record output of timeit in variable

How can I record in a variable the amount of time taken by a function? I read somewhere that timeit is the good way to time stuff, but it seems to print its output instead of returning it.

If possible, I would prefer not to redirect streams or redefine print, etc.

EDIT: got it, leaving the question for reference. timeit("blah",seconds=True) returns a number. This should probably get a mention in 'timeit?'.

click to hide/show revision 5
No.5 Revision

Record output of timeit in variable

How can I record in a variable the amount of time taken by a function? I read somewhere that timeit is the good way to time stuff, but it seems to print its output instead of returning it.

If possible, I would prefer not to redirect streams or redefine print, etc.

EDIT: got it, leaving the question for reference. reference.

timeit("blah",seconds=True) returns a number. number.

This should probably get a mention in 'timeit?'.

click to hide/show revision 6
No.6 Revision

Record output of timeit in variable

How can I record in a variable the amount of time taken by a function? I read somewhere that timeit is the good way to time stuff, but it seems to print its output instead of returning it.

If possible, I would prefer not to redirect streams or redefine print, etc.

EDIT: got it, leaving the question for reference.

timeit("blah",seconds=True) returns a number.

This should probably get a mention in 'timeit?'.

click to hide/show revision 7
No.7 Revision

Record output of timeit in variable

How can I record in a variable the amount of time taken by a function? I read somewhere that timeit is the good way to time stuff, but it seems to print its output instead of returning it.

If possible, I would prefer not to redirect streams or redefine print, etc.


EDIT: got it, leaving the question for reference.

timeit("blah",seconds=True) returns a number.

This should probably get a mention in 'timeit?'.

click to hide/show revision 8
Please please stop messing up new lines. One shouldn't have to use br.

Record output of timeit in variable

How can I record in a variable the amount of time taken by a function? I read somewhere that timeit is the good way to time stuff, but it seems to print its output instead of returning it.

If possible, I would prefer not to redirect streams or redefine print, etc.


EDIT: got it, leaving the question for reference.

timeit("blah",seconds=True) returns a number.

This should probably get a mention in 'timeit?'.

click to hide/show revision 9
No.9 Revision

updated 13 years ago

Jason Grout gravatar image

Record output of timeit in variable

How can I record in a variable the amount of time taken by a function? I read somewhere that timeit is the good way to time stuff, but it seems to print its output instead of returning it.

If possible, I would prefer not to redirect streams or redefine print, etc.


EDIT: got it, leaving the question for reference.

timeit("blah",seconds=True) returns a number.

number.

This should probably get a mention in 'timeit?'.

click to hide/show revision 10
No.10 Revision

updated 13 years ago

Jason Grout gravatar image

Record output of timeit in variable

How can I record in a variable the amount of time taken by a function? I read somewhere that timeit is the good way to time stuff, but it seems to print its output instead of returning it.

If possible, I would prefer not to redirect streams or redefine print, etc.


EDIT: got it, leaving the question for reference.

timeit("blah",seconds=True) timeit("blah",seconds=True)

returns a number. number.

This should probably get a mention in 'timeit?'.