Pages

10/18/2014

Windows Server 2008R2 Disk Cleanup Utility

Disk Cleanup, like in Win7 is available by installing the Desktop Experience feature.
You can run it without installing Desktop Experience feature by doing the following:

Copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.1.7600.16385_none_c9392808773cd7da\cleanmgr.exe C:\Windows\System32\
copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.1.7600.16385_en-us_b9cb6194b257cc63\cleanmgr.exe.mui C:\Windows\System32\en-US\
cleanmgr.exe /verylowdisk
You can put the above in a BAT file and it will copy the files and run without user intervention. Or just copy the files and run it to select options. run using cleanmgr.exe /? to see interesting switches for saving your selected options.

Calculating the past growth rate

I want to be able to determine the annual growth rate of data in a directory structure. I know it was created at a certain date and only "new" data was written there -- nothing was migrated from another directory structure.


Mathematically
the total $lastyear would be  $now  / (1 + $growthrate)
so the total  $pastyear $num years ago would be  $now  / (1 + $growthrate)^$num  .
but I am not sure if that would work all the way back to the first year when the total was 0 (if I use 1 GB to approximate zero, especially if the number of years is short, for example 2-3)


Solving for $growthrate:


    $pastyear = $now / ((1 + $growthrate)^$num)


    $pastyear * ((1 + $growthrate)^$num) = $now


    ((1 + $growthrate)^$num) = $now / $pastyear


    1 + $growthrate = ($now / $pastyear)^(1/$num)


    $growthrate = (($now / $pastyear)^(1/$num)) - 1


looking at the above if the $pastyear is very small to approximate zero and $num is pretty small this looks like it will be much bigger than is reasonable.


Subtly
For this specific purpose I could attempt to take a file listing of all the files in the directory structure.  Using Excel for instance:
- import the file listing above, use text to columns to split into fields, hide or delete all but date & file size
- create a 3rd column in between with formula calculating just the year of the date
- sort them by year newest to oldest
- group by year & subtotal the file size
this will tell me how much was there the first year
**when I ignore "growth" during the first year and use the amount at the end of the first year in the above formula it seems to be much more reasonable.

10/09/2014

Don't pad number strings, use modular arithmetic to calculate each digit

Example in Python:
// = integer division
% = remainder

# given t in tenths of seconds, 
# return a string of format string A:BC.D
# A = minutes, BC = seconds, with leading zero if needed, D = tenths of seconds
def format(t):
    tenths = t % 10
    t = t // 10
    sec = t % 60
    min = t // 60
    sec_ones = sec % 10
    sec_tens = sec // 10
    display = str(min) + ":" + str(sec_tens) + str(sec_ones) + "." + str(tenths)
    return display

9/30/2014

Test time to open Word documents of various sizes

Goal: Test to gather the time to open and save various size documents

function sleep(milliseconds) {
 var start = new Date().getTime();
 for (var i = 0; i < 1e7; i++) {
  if ((new Date().getTime() - start) > milliseconds){
   break;
   }
  }
 }

var myApp = new ActiveXObject("Word.Application");
myApp.Visible = true;

// Open 200K
var smopenstart = new Date().getTime();
  myApp.Documents.Open("Z:\\200K.doc");
var smopenend = new Date().getTime();

//wait 10 s
sleep(10000);

// Save 200K
var smsavestart = new Date().getTime();
  myApp.ActiveDocument.SaveAs("Z:\\NEW\\200K.doc");
var smsaveend = new Date().getTime();

// Close 200K
myApp.Documents.Close();

//quit Word
myApp.Application.Quit();

//wait 10 s
sleep(10000);

var myApp = new ActiveXObject("Word.Application");
myApp.Visible = true;

// Open 1MB
var medopenstart = new Date().getTime();
  myApp.Documents.Open("Z:\\1M.doc");
var medopenend = new Date().getTime();

//wait 10 s
sleep(10000);

// Save 1MB
var medsavestart = new Date().getTime();
  myApp.ActiveDocument.SaveAs("Z:\\NEW\\1M.doc");
var medsaveend = new Date().getTime();

// Close 1MB
myApp.Documents.Close();

//quit Word
myApp.Application.Quit();


//wait 10 s
sleep(10000);

var myApp = new ActiveXObject("Word.Application");
myApp.Visible = true;

// Open 5MB
var lrgopenstart = new Date().getTime();
  myApp.Documents.Open("Z:\\5M.doc");
var lrgopenend = new Date().getTime();

//wait 10 s
sleep(10000);

// Save 5MB
var lrgsavestart = new Date().getTime();
  myApp.ActiveDocument.SaveAs("Z:\\NEW\\5M.doc");
var lrgsaveend = new Date().getTime();

// Close 5MB
myApp.Documents.Close();

//quit Word
myApp.Application.Quit();

//define date string
var mo = new Date().getMonth()+1;
if (mo < 10) { mo = "0" + mo };
var day = new Date().getDate();
if (day < 10) {day = "0" + day};
var year = new Date().getFullYear();
var hrs = new Date().getHours();
if (hrs < 10) {hrs = "0" + hrs};
var m = new Date().getMinutes();
if (m < 10) {m = "0" + m};
var s = new Date().getSeconds();
if (s < 10) {s = "0" + s};
var dt = mo + "/" + day + "/" + year + " " + hrs + ":" + m + ":" + s

//Calculate times
var smopentime = (smopenend - smopenstart)/1000
var smsavetime = (smsaveend - smsavestart)/1000
var medopentime = (medopenend - medopenstart)/1000
var medsavetime = (medsaveend - medsavestart)/1000
var lrgopentime = (lrgopenend - lrgopenstart)/1000
var lrgsavetime = (lrgsaveend - lrgsavestart)/1000

//output results
WScript.Echo(dt, ",", smopentime, ",", smsavetime, ",", medopentime, ",", medsavetime, ",", lrgopentime, ",", lrgsavetime);
Save above as "openword.js" and call with the following BAT file

net use Z: \\SHARE\TEST\ATL
c:
cd\temp
cscript //NoLogo c:\temp\openword.js >> CHI.log
echo y | del z:\new\*.*
net use z: /delete