Skip to content

Instantly share code, notes, and snippets.

@nukino
Created March 15, 2012 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nukino/2041196 to your computer and use it in GitHub Desktop.
Save nukino/2041196 to your computer and use it in GitHub Desktop.
[20120315-1101]million_make.js/○万ファイル作成(JScript版)
if ( true )
{
var g_max_depth = 100;
var g_file_count = 10000;
}
else
{
var g_max_depth = 10;
var g_file_count = 1000;
}
var g_depth = 0;
var g_wshShell = WScript.CreateObject("WScript.Shell");
var g_wshFileSys = new ActiveXObject("Scripting.FileSystemObject");
function make_files(dir, count)
{
var i;
if ( !g_wshFileSys.FolderExists( dir ) )
g_wshFileSys.CreateFolder( dir );
if ( !g_wshFileSys.FolderExists( dir ) )
return;
for ( i = 0; i < count; i++ )
{
var base_fname = ("0000" + i);
base_fname = base_fname.substr(base_fname.length-5,5);
var filename = g_wshFileSys.BuildPath( dir, base_fname );
var file = g_wshFileSys.CreateTextFile( filename, true, false );
var date = new Date();
file.WriteLine( date.toString() );
file.WriteLine( date.toUTCString() );
file.WriteLine( date.toLocaleString() );
file.Close();
file = null;
date = null;
if ( i % 100 )
WScript.Sleep(1); // ガベージコレクト期待
}
WScript.Sleep(100); // ガベージコレクト期待
}
{
var dir = "C:\\";
var depth;
if ( WScript.Arguments.length > 0 )
dir = WScript.Arguments(0);
if ( WScript.Arguments.length > 1 )
g_max_depth = WScript.Arguments(1);
for ( depth = 0; depth < g_max_depth; depth++ )
{
var date = new Date();
WScript.Echo(date.toLocaleString()+" "+depth*100/g_max_depth+"%");
make_files( dir, g_file_count );
dir = g_wshFileSys.BuildPath( dir, "a" );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment