[Miscellaneous] A small test about as

code show as below:

Well, we already knew that ASender must be an object of type TButton, and then looped 100 million times to amplify the problem. Let's look at the output:

as time:578ms
direct time:219ms

That is, casting with as takes 2.7 times longer than casting directly. According to the statistical node, 100 million times takes 578 ms, and the difference per million times is about 3.6 ms. The actual difference is not as scary as the ratio looks. However, in the program, if you clearly know the type, it seems that there is nothing bad about using coercion, and the workload of entering two spaces is less, which seems quite cost-effective, but due to the position of (), the actual input may be slower. Well, Virgo people, let's go. I personally think it's better to turn a little bit stronger. No matter how small a mosquito is, it's still meat.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325119374&siteId=291194637