May 20, 2008
Syracuse, NY, USA
When I write plugins, I speed-test those things I want to be fast. Ever since I got my current computer (quad-core) it has been difficult to reproduce speed-test results. They'd be reproducible in one instance of TCC but (reproducibly) different in another. Occasionally I'd get lucky and see results 10% faster than others and then not be able to reproduce them in another shell.

So (after getting the idea) I wrote a plugin, AFFINITY, to investigate the processors. AFFINITY lets the user see the system "affinity mask" (_SYSAFFIN, a bitmap of the processors available to the system) and the process affinity mask (_AFFINITY). It also lets the user recommend a processor for the current thread (with IDEAL) and demand a processor (or a collection of them) for the thread or process by specifying a new thread or process affinity mask (with AFFINITY). [More details below]

Results like these are reproducible.

v:\> for %j in (1 2 4 8) (affinity /t %j & echo ^r^nAffinity mask: %j (was %_?)& for /L %k in (1,1,3) (timer /q & for /l %i in (1,1,1000) (lc hammer.txt > nul) & timer))

Affinity mask: 1 (was 15)
Timer 1 off: 22:28:57  Elapsed: 0:00:00.97
Timer 1 off: 22:28:58  Elapsed: 0:00:00.97
Timer 1 off: 22:28:59  Elapsed: 0:00:00.97

Affinity mask: 2 (was 1)
Timer 1 off: 22:29:00  Elapsed: 0:00:01.11
Timer 1 off: 22:29:01  Elapsed: 0:00:01.09
Timer 1 off: 22:29:02  Elapsed: 0:00:01.09

Affinity mask: 4 (was 2)
Timer 1 off: 22:29:03  Elapsed: 0:00:01.03
Timer 1 off: 22:29:04  Elapsed: 0:00:01.04
Timer 1 off: 22:29:05  Elapsed: 0:00:01.03

Affinity mask: 8 (was 4)
Timer 1 off: 22:29:06  Elapsed: 0:00:01.03
Timer 1 off: 22:29:07  Elapsed: 0:00:01.05
Timer 1 off: 22:29:08  Elapsed: 0:00:01.03
They show I have one processor which is detectably faster than the others and one which is detectable slower. Why? I don't know. It could be hardware; it could be how the system process makes use of them.

I've done a lot of horsing around and had no ill effects (but no promises). I doubt AFFINITY will be of much practical value. But if you have a multi-processor machine it could provide a few minutes of recreation. I have no idea if non-admins can use it (and less of an idea than that of how it will fare on Vista or Win7). I put (32-bit only for now) on and (FTP).

More details:

v:\> affinity /?
AFFINITY /T(hread) | /P(rocess)  N - set affinity mask to N (_? = old mask)
The process mask must be a subset of the system mask (_SYSAFFIN)
The thread mask must be a subset of the process mask (_AFFINITY)
Affinity masks are bitmaps; bit n corresponds to processor n (n = 0 to 31)
On a quad-core, for example, the mask 15 means any processor
and the masks for the individual processors are 1, 2, 4 and 8

v:\> ideal
IDEAL N - recommend a processor for this thread; N = 0 to 3
Similar threads
Thread starter Title Forum Replies Date
Joe Caverly 64-bit Plugin development using PureBasic Plugins 15
R New Plugin Plugins 0
Alpengreis elevated plugin questions Plugins 3
fpefpe utf-8 support in sdk/plugin api Plugins 4
S How to? Can @DU function in 4Utils64 plugin somehow cater for dirs with spaces? Plugins 3
vefatica Plugin access to arrays? Plugins 4
vefatica How big is a plugin's parameter buffer? Plugins 5
C @knownpath plugin Plugins 0
Charles Dye Updated OSD plugin Plugins 0
Joe Caverly C# plugin framework for JPSoft's TCC Plugins 0
dcantor Help for newest version of TEXTUTILS plugin Plugins 10
dcantor UISTUFF plugin missing help topic Plugins 12
M How to? Use SafeChars plugin... Plugins 2
dcantor Error in SAFECHARS plugin v 1.9.0 Plugins 2
dcantor Request for documentation for ISO8601 plugin Plugins 4
vefatica Possible with a plugin? Plugins 6
dcantor Inconsistency between textutils plugin and wrap utility Plugins 2
M (Stupid?) Problem with 64-bit 4Utils plugin... Plugins 3
H Latest ISO8601 plugin? Plugins 1
Charles Dye New plugin: QKeys Plugins 34
S Plugin to quickly locate all files hard linked together Plugins 5
S Documentation Plugin everything.dll Plugins 5
newbie How to? Multi-plugin installation errors, Re: FedUtils8 Plugins 7
vefatica Plugin -> thread -> Command() -> Ctrl-C? Plugins 20
Charles Dye A weirdoid plugin question Plugins 6
M SafeChars plugin misbehaving... Plugins 3
M A weird error re a plugin... Plugins 0
vefatica Plugin dilemma Plugins 2
fpefpe Documentation Plugin API/SDK Plugins 3
C Looking for Vince's old 4UTILS plugin for TCMD v8 Plugins 1
S DESKTOP plugin - anyone ? Plugins 0
C How to? a plugin to sort Outlook Express "rules" Plugins 0
M ISO Plugin: Yes, it's wonderful, but it could be yet more wonderful... Plugins 7
M The ISO plugin is wonderful, but it lacks a little something... Plugins 22
Charles Dye Beta plugin: HidePasswords Plugins 3
M ISO8601 Plugin not "reporting" errors to TCC... Plugins 4
Frank 4console plugin Plugins 4
S WAD ISO8601 Plugin Plugins 15
Joe Caverly Plugin and 64-bit TCC Plugins 3
C Problem with FixNames plugin Plugins 9
dcantor Suggestion and request for DBF plugin Plugins 6
dcantor Suggestion for SafeChars plugin Plugins 7
M Charles, I just installed the "new" SafeChars plugin, ... Plugins 5
M A problem with the SafeChars Plugin... Plugins 30
S WHICHWIN (sysutils plugin) Plugins 13
M A (presumbly pretty simple) SafeChars plugin request... Plugins 2
M A "SafeChars" plugin request... Plugins 2
S ISO 8601 plugin enhancement Plugins 6
D UNKNOWN_CMD in Plugin Plugins 13
C Looking for isemailaddress[string] plugin Plugins 7

Similar threads