[Question | Any Programming Language] Script to check L2/L3 processor cache?

Discussion in 'Scripting' started by lysy.lbn, Jul 23, 2011.

  1. lysy.lbn

    lysy.lbn MDL Member

    Apr 20, 2011
    125
    65
    10
    It`s possible to make script which check how much L2/L3 cache have processor?
    and make action "if 2048 then goto reg2m, if 4096 then goto reg4m"
    (of course it could be in any programming language, but I preferred batch or visual basic)
     
  2. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    #2 stevemk14ebr, Jul 24, 2011
    Last edited: Jul 25, 2011
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Compo

    Compo MDL Member

    Mar 29, 2011
    137
    103
    10
    #3 Compo, Jul 25, 2011
    Last edited by a moderator: Apr 20, 2017
    Using the above you could implement something like this:
    Code:
    @ECHO OFF
    SETLOCAL ENABLEEXTENSIONS
    
    REM FOR /F "TOKENS=5,7 DELIMS= " %%A IN (
    REM'E:\UTILITIES\CKCPU208\CHKCPU32.EXE /V^|FIND "L2"') DO SET/A L2=%%A * %%B
    
    FOR /F "TOKENS=5 DELIMS= " %%A IN (
    'C:\UTILITIES\CKCPU208\CHKCPU32.EXE /V^|FIND "L3"') DO SET L3=%%A
    
    REM ECHO=Your Level 2 cache is %L2%KB 
    
    IF %L3% GEQ 4096 GOTO REG4M
    IF %L3% GEQ 2048 GOTO REG2M
    ECHO=Level 3 cache is less than 2MB
    GOTO :END
    
    :REG4M
    REM Commands for L3 cache of min 4MB
    GOTO :END
    
    :REG2M
    REM Commands for L3 cache of min 2MB less than 4MB 
    
    :END
    ENDLOCAL
    GOTO :EOF
    I REMarked out the Level 2 cache commands since I'm guessing your question related to Level 3 cache. I left them there for information, just in case someone required them.