简体   繁体   English

如何强制RAM编程?

[英]How to force RAM to program?

I am about to make batch program, and then compile it with BAT to EXE converter. 我要制作批处理程序,然后用BAT编译为EXE转换器。 If I am making program like 如果我正在制作像

@echo off
set Line=0
:Start
set /a Line=%Line% + 1
echo %Line%
goto :Start

I see each time, previous number, +1. 我每次看到的都是前一个+1。

This goes quite fast, but I can still follow sequence. 这进行得相当快,但是我仍然可以按照顺序进行。

I know that computers are thousands times faster, since they have to calculate much much more for computer itself. 我知道计算机的速度要快数千倍,因为它们必须为计算机本身计算更多的信息。

Is there possibility to force additional performance for program? 是否有可能强制程序提高性能? Reserving RAM, or anything like it? 保留RAM还是类似的东西?

code, you can test: 代码,您可以测试:

@echo off & SETLOCAL
for /l %%i in (0) do <nul set/p=.

@echo off & SETLOCAL
:loop
SET /a var+=1
ECHO %var%
goto:loop

You can make it about a million times faster by using a real programming language. 使用真正的编程语言,您可以使其速度提高大约一百万倍。

In batch, you are actually executing plain text commands, which are individually parsed and executed by the command interpreter. 批处理实际上是在执行纯文本命令,这些命令由命令解释器单独解析和执行。 This was never optimized for speed. 从来没有针对速度进行过优化。 A batch to exe convertor does little more than wrap the code of a batch file and feed it to the command interpreter, so it doesn't execute any (or at least not much) faster than a regular batch file. 批处理文件到exe转换器的作用不只是包装批处理文件的代码并将其馈送到命令解释器,因此它的执行速度(或至少不快于常规批处理文件)。

Extra RAM doesn't mean extra performance by the way. 额外的RAM并不意味着额外的性能。 Extra RAM only gives you extra performance if your application has too little RAM available to fit all its data in. If that happens, a part of your application's memory is swapped to disk, causing an extra performance hit. 仅当应用程序的可用RAM太少而无法容纳所有数据时,额外的RAM才会为您提供额外的性能。如果发生这种情况,则应用程序的一部分内存会交换到磁盘上,从而导致性能下降。 But there's not much you can do about that in batch anyway. 但是无论如何,您对此无能为力。

Many programming languages have compilers which convert your code to actual machine instructions, or at least instructions for a highly optimized virtual machine, like .NET or JVM. 许多编程语言都有编译器,这些编译器会将您的代码转换为实际的机器指令,或者至少将其转换为高度优化的虚拟机(例如.NET或JVM)的指令。 Even scripting languages like PHP are highly optimized, because they need to be able to execute large chunks of code in very little time. 甚至PHP之类的脚本语言也得到了高度优化,因为它们需要能够在极短的时间内执行大量代码。 For batch, this is not the case. 对于批处理,情况并非如此。 You're just missing the purpose of what batch is, which is repeating a lot of command line instructions, because you don't want to have to type them in every time. 您只是错过了批处理的目的,它重复了很多命令行指令,因为您不想每次都键入它们。 ;-) ;-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM