下面代码中的行set cyclezipPPMdd=%cyclezipPPMdd!cycleCount!%
没有按我的意图工作。!cycleCount!
例如,它应该转换为 ,1
然后转换%cyclezipPPMdd!cycleCount!%
为cyclezipPPMdd1
并最终设置cyclezipPPMdd
为等于 的cyclezipPPMdd1
值256m
。
我需要一个旋转值cyclezipPPMdd
。
rem @echo off
setlocal enableDelayedExpansion
: part1
set "cyclezipPPMdd0=256m 128m 64m 32m 16m 8m 4m 2m 1m"
set "memcyclezipPPMdd=258 130 66 34 18 10 6 4 3"
set /a anotherCounter=0
set tempCycle=!cyclezipPPMdd0: =^
!
for /f %%i in ("!tempCycle!") do (
set /a anotherCounter+=1
set cyclezipPPMdd!anotherCounter!=%%i
)
set /a cycleCount=0
: part2
set tempMem=!memcyclezipPPMdd: =^
!
for /f %%i in ("!tempMem!") do (
set /a cycleCount+=1
set tempMem!cycleCount!=%%i
set cyclezipPPMdd=%cyclezipPPMdd!cycleCount!%
set cyclezipPPMdd
pause
)
set /a anotherCounter=0
set /a cycleCount=0
pause
最后,我对我需要做什么来实现我的目标一无所知。我根本不是程序员。这是最终目标主题:for and start commands in a batch for parallel and sequence work
编辑:太久没读过的版本
我需要一种方法来拆分cyclezipPPMdd0=256m 128m 64m 32m 16m 8m 4m 2m 1m
成单个部分,如下所示:
cyclezipPPMdd0=256m 128m 64m 32m 16m 8m 4m 2m 1m
cyclezipPPMdd1=256m
cyclezipPPMdd2=128m
cyclezipPPMdd3=64m
cyclezipPPMdd4=32m
cyclezipPPMdd5=16m
cyclezipPPMdd6=8m
cyclezipPPMdd7=4m
cyclezipPPMdd8=2m
cyclezipPPMdd9=1m
这些值将直接影响 7z.exe 将使用多少内存(在另一个主题中解释),我需要一种方法来跟踪当前正在使用多少内存以确定剩余内存是否允许我是否运行另一个 7z.exe 实例。当 7z.exe 启动时,它一次只会使用其中一个值。但是,256m 是 7z.exe 的一个参数值,它是字典大小。这个参数的实际内存使用量是258,所以,关联的值是这样的:
cyclezipPPMdd1=256m <=> tempMem1=258
cyclezipPPMdd2=128m <=> tempMem2=130
cyclezipPPMdd3=64m <=> tempMem3=66
cyclezipPPMdd4=32m <=> tempMem4=34
cyclezipPPMdd5=16m <=> tempMem5=18
cyclezipPPMdd6=8m <=> tempMem6=10
cyclezipPPMdd7=4m <=> tempMem7=6
cyclezipPPMdd8=2m <=> tempMem8=4
cyclezipPPMdd9=1m <=> tempMem9=3
7z.exe 目前在我的代码上设置为读取值cyclezipPPMdd
(不带数字)。这个变量必须在所有可用的部分中旋转,从 拆分cyclezipPPMdd0
,但始终是相同的名称,cyclezipPPMdd
(仍然没有数字)。
if defined cyclezipPPMd (
for %%x IN (%cyclezipPPMdx%) DO for %%t IN (%cyclezipPPMdt%) DO for %%d IN (%cyclezipPPMdd%) DO for %%w IN (%cyclezipPPMdw%) DO (
set "cmd=7z.exe a teste.resultado\%%xx.ppmd.%%tt.%%dd.%%ww.zip .\teste.original\* -mx=%%x -mm=PPMd:mem=%%d:o=%%w -mmt=%%t"
call :executeProc
)
)
第一次 7z.exe 运行会做cyclezipPPMdd=256m
,第二次运行会做cyclezipPPMdd=128m
等等......像这样:
first run
cyclezipPPMdd1=256m <=> tempMem1=258 -> cyclezipPPMdd=256m
cyclezipPPMdd2=128m <=> tempMem2=130
cyclezipPPMdd3=64m <=> tempMem3=66
cyclezipPPMdd4=32m <=> tempMem4=34
cyclezipPPMdd5=16m <=> tempMem5=18
cyclezipPPMdd6=8m <=> tempMem6=10
cyclezipPPMdd7=4m <=> tempMem7=6
cyclezipPPMdd8=2m <=> tempMem8=4
cyclezipPPMdd9=1m <=> tempMem9=3
second run
cyclezipPPMdd1=256m <=> tempMem1=258
cyclezipPPMdd2=128m <=> tempMem2=130 -> cyclezipPPMdd=128m
cyclezipPPMdd3=64m <=> tempMem3=66
cyclezipPPMdd4=32m <=> tempMem4=34
cyclezipPPMdd5=16m <=> tempMem5=18
cyclezipPPMdd6=8m <=> tempMem6=10
cyclezipPPMdd7=4m <=> tempMem7=6
cyclezipPPMdd8=2m <=> tempMem8=4
cyclezipPPMdd9=1m <=> tempMem9=3
third run
cyclezipPPMdd1=256m <=> tempMem1=258
cyclezipPPMdd2=128m <=> tempMem2=130
cyclezipPPMdd3=64m <=> tempMem3=66 -> cyclezipPPMdd=64m
cyclezipPPMdd4=32m <=> tempMem4=34
cyclezipPPMdd5=16m <=> tempMem5=18
cyclezipPPMdd6=8m <=> tempMem6=10
cyclezipPPMdd7=4m <=> tempMem7=6
cyclezipPPMdd8=2m <=> tempMem8=4
cyclezipPPMdd9=1m <=> tempMem9=3
etc...
然而,这还不是全部。还有另一个 7z.exe 参数不仅会影响将使用多少内存,还会影响将使用多少线程。我的脚本中没有准备好这部分,我仍在试图弄清楚如何实现它。
first cycle <=> cyclezipPPMdt1=1 <=> tempProc1=8
first run
cyclezipPPMdd1=256m <=> tempMem1=258 -> cyclezipPPMdd=256m
cyclezipPPMdd2=128m <=> tempMem2=130
second run
cyclezipPPMdd1=256m <=> tempMem1=258
cyclezipPPMdd2=128m <=> tempMem2=130 -> cyclezipPPMdd=128m
etc...
second cycle <=> cyclezipPPMdt2=2 <=> tempProc2=4
first run
cyclezipPPMdd1=256m <=> tempMem1=580 -> cyclezipPPMdd=256m
cyclezipPPMdd2=128m <=> tempMem2=324
second run
cyclezipPPMdd1=256m <=> tempMem1=580
cyclezipPPMdd2=128m <=> tempMem2=324 -> cyclezipPPMdd=128m
etc...
下表显示了 zipPPMd 算法的内存使用、线程使用和压缩强度之间的关系。
@echo off
echo mem=1m 2m 4m 8m 16m 32m 64m 128m 256m
echo o=2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
echo mt=1 2 3 4 5 6 7 8
echo x=1 3 5 7 9
echo 256m 9x 7x 5x 3x 1x 8t - 2320 MB, 7t - 2030 MB, 6t - 1740 MB, 5t - 1450 MB, 4t - 1160 MB, 3t - 870 MB, 2t - 580 MB, 1t - 258 MB
echo 128m 9x 7x 5x 3x 1x 8t - 1296 MB, 7t - 1134 MB, 6t - 972 MB, 5t - 810 MB, 4t - 648 MB, 3t - 486 MB, 2t - 324 MB, 1t - 130 MB
echo 64m 9x 7x 5x 3x 1x 8t - 784 MB, 7t - 686 MB, 6t - 588 MB, 5t - 490 MB, 4t - 392 MB, 3t - 294 MB, 2t - 196 MB, 1t - 66 MB
echo 32m 9x 7x 5x 3x 1x 8t - 528 MB, 7t - 462 MB, 6t - 396 MB, 5t - 330 MB, 4t - 264 MB, 3t - 198 MB, 2t - 132 MB, 1t - 34 MB
echo 16m 9x 7x 5x 3x 1x 8t - 400 MB, 7t - 350 MB, 6t - 300 MB, 5t - 250 MB, 4t - 200 MB, 3t - 150 MB, 2t - 100 MB, 1t - 18 MB
echo 8m 9x 7x 5x 3x 1x 8t - 336 MB, 7t - 294 MB, 6t - 252 MB, 5t - 210 MB, 4t - 168 MB, 3t - 126 MB, 2t - 84 MB, 1t - 10 MB
echo 4m 9x 7x 5x 3x 1x 8t - 304 MB, 7t - 266 MB, 6t - 228 MB, 5t - 190 MB, 4t - 152 MB, 3t - 114 MB, 2t - 76 MB, 1t - 6 MB
echo 2m 9x 7x 5x 3x 1x 8t - 288 MB, 7t - 252 MB, 6t - 216 MB, 5t - 180 MB, 4t - 144 MB, 3t - 108 MB, 2t - 72 MB, 1t - 4 MB
echo 1m 9x 7x 5x 3x 1x 8t - 280 MB, 7t - 245 MB, 6t - 210 MB, 5t - 175 MB, 4t - 140 MB, 3t - 105 MB, 2t - 70 MB, 1t - 3 MB
无论压缩强度(x
在这个表中定义,和%cyclezipPPMdx%
在脚本中定义),当字典(mem
在表中,%cyclezipPPMdd%
在脚本中)设置为例如256m时,对应的实际内存使用量(tempMem#
在脚本中)将为取决于定义了多少线程(mt
在表中,%cyclezipPPMdt%
在脚本中)。
该序列set "memcyclezipPPMdd=258 130 66 34 18 10 6 4 3"
来自该表的最后一列。