I thought that alias performance is between proc and proc wrapper. May be i used something wrong? Is there solution to give a proc just an alias(a second name) which point to the same code(and thus give the same performance)?
(On my machine, the two test case speeds are quite a bit closer. No idea why.)
I'd guess that what the alias gains in not having to manipulate a stack frame it loses in the complexity for passing through arguments. If you want to do something more comparable in terms of functionality, try with this:
proc test3 args {test {*}$args}
I find that to be slower than the other examples (using tailcall as well makes it even slower still).
Hi, all.
I've done the next experiment with alias performance measurement:
% proc test {} { set a 1; }
% proc test1 {} { test; }
% interp alias {} test2 {} test
test2
% time test 1000000
0.426097 microseconds per iteration
% time test1 1000000
0.656562 microseconds per iteration
% time test2 1000000
0.755594 microseconds per iteration
I thought that alias performance is between proc and proc wrapper. May be i used something wrong? Is there solution to give a proc just an alias(a second name) which point to the same code(and thus give the same performance)?
Is this can be used in production code or i missed something?
On Monday, 4 October 2021 at 13:14:51 UTC+1, Oleg O. Nemanov wrote:the alias. If both parts are implemented in code you control, that's trivially handled by reference counting the structure (and arguably it becomes two equivalent names for the one thing). If not, only the high level guarantees of how you write your
Is this can be used in production code or i missed something?It's unsafe because the lifetime of the value in the clientData field (well, the lifetime of the structure it points to) isn't being handled right. You'd get away with it in production code, but *only* if the target command lives at least as long as
The safer thing with general aliasing is to dispatch indirectly (Tcl_EvalObjv is the most direct route into this) but then you've got the additional costs of more memory management as well as copying the argument references.
And this will be the same speed as pure tcl test3 proc?
I've done the next experiment with alias performance measurement:
% proc test {} { set a 1; }
% proc test1 {} { test; }
% interp alias {} test2 {} test
test2
% time test 1000000
0.426097 microseconds per iteration
% time test1 1000000
0.656562 microseconds per iteration
% time test2 1000000
0.755594 microseconds per iteration
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 285 |
Nodes: | 16 (2 / 14) |
Uptime: | 32:51:02 |
Calls: | 6,449 |
Calls today: | 1 |
Files: | 12,052 |
Messages: | 5,254,898 |