String.prototype.trim=function(){return this.replace(/(^\s*)|(\s*$)/g,"");};String.prototype.toFloat=function(){return(isNaN(parseFloat(this)))?0:parseFloat(this);};String.prototype.toInt=function(){return(isNaN(parseInt(this,10)))?0:parseInt(this,10);};String.prototype.padZero=function(){return(this.toInt()<10)?"0"+this:this;};var INITIAL_ELEMENT_ID_TO_FOCUS="diskchoice";function roundNumber(num,dec){var result=(Math.round(Math.round(num*Math.pow(10,dec+1))/Math.pow(10,1))/Math.pow(10,dec));return result;}function pad_with_zeros(rounded_value,decimal_places){var value_string=rounded_value.toString();var decimal_location=value_string.indexOf(".");if(decimal_location===-1){decimal_part_length=0;value_string+=decimal_places>0?".":"";}else{decimal_part_length=value_string.length-decimal_location-1;}var pad_total=decimal_places-decimal_part_length;if(pad_total>0){for(var counter=1;counter<=pad_total;counter++){value_string+="0";}}return value_string;}function Write(pOutputElementId,pValue){document.getElementById(pOutputElementId).innerHTML=pValue;}function HideShowForm(pElement){var oWrapper=document.getElementById("formwrapper");var sDisplay=oWrapper.style.display;if(oWrapper.style.display==="none"){oWrapper.style.display="block";pElement.innerHTML="Hide Form";document.getElementById(INITIAL_ELEMENT_ID_TO_FOCUS).focus();}else{oWrapper.style.display="none";pElement.innerHTML="Show Form";}}function get_RAIDLevel(){switch(RAID_LEVEL){case 1:return"RAID 0";case 2:return"RAID 10";case 4:return"RAID 5";case 6:return"RAID 6";}}function Get_IOTypeValues(){return"Avg "+IO_PATTERN.replace("Both","Random/Sequential")+" "+IO_TYPE.replace("Both","Read/Write")+" IOPs";}function Get_IOTypeValuesMBSec(){return"Avg "+IO_PATTERN.replace("Both","Random/Sequential")+" "+IO_TYPE.replace("Both","Read/Write")+" MB/Sec";}function Get_IOTypeValuesMBSecIOSize(){return"Avg "+IO_PATTERN.replace("Both","Random/Sequential")+" "+IO_TYPE.replace("Both","Read/Write")+" "+IO_SIZE+"KB Block MB/Sec";}function Get_IOTypeValuesMBSecSectorSize(){return"Avg "+IO_PATTERN.replace("Both","Random/Sequential")+" "+IO_TYPE.replace("Both","Read/Write")+" "+(DISK_SECTOR_SIZE*1000)+" Byte Sector MB/Sec";}function Get_OutRaidCapacity(){return"Capacity of  "+get_RAIDLevel()+" Array in GB";}function Calc_SequentialReadIO(){return roundNumber(1000/(SEQUENTIAL_SEEK_READ+(ROTATIONAL_LATENCY)),2);}function Calc_RandomReadIO(){return roundNumber(1000/(RANDOM_SEEK_READ+(ROTATIONAL_LATENCY)),2);}function Calc_SequentialWriteIO(){return roundNumber(1000/(SEQUENTIAL_SEEK_WRITE+(ROTATIONAL_LATENCY)),2);}function Calc_RandomWriteIO(){return roundNumber(1000/(RANDOM_SEEK_WRITE+(ROTATIONAL_LATENCY)),2);}function Avg_IOPs(){switch(IO_TYPE.toLowerCase()){case"read":switch(IO_PATTERN.toLowerCase()){case"random":return roundNumber((DISKS*Calc_RandomReadIO())/((1+((IO_SIZE*1/DISK_SECTOR_SIZE)-1)/(STRIPE_SIZE*1/DISK_SECTOR_SIZE))*(1-CACHE_HIT_RATIO_READS/100)),2);case"sequential":return roundNumber((DISKS*Calc_SequentialReadIO())/(RAID_LEVEL*(1+((IO_SIZE*1/DISK_SECTOR_SIZE)-1)/(STRIPE_SIZE*1/DISK_SECTOR_SIZE))*(1-CACHE_HIT_RATIO_WRITES/100)),2);case"both":return roundNumber((DISKS*(Calc_SequentialReadIO()+Calc_RandomReadIO())/2)/((1+((IO_SIZE*1/DISK_SECTOR_SIZE)-1)/(STRIPE_SIZE*1/DISK_SECTOR_SIZE))*(1-CACHE_HIT_RATIO_READS/100)),2);}break;case"write":switch(IO_PATTERN.toLowerCase()){case"random":return roundNumber((DISKS*Calc_RandomWriteIO())/(RAID_LEVEL*(1+((IO_SIZE*1/DISK_SECTOR_SIZE)-1)/(STRIPE_SIZE*1/DISK_SECTOR_SIZE))*(1-CACHE_HIT_RATIO_WRITES/100)),2);case"sequential":return roundNumber((DISKS*Calc_SequentialWriteIO())/(RAID_LEVEL*(1+((IO_SIZE*1/DISK_SECTOR_SIZE)-1)/(STRIPE_SIZE*1/DISK_SECTOR_SIZE))*(1-CACHE_HIT_RATIO_WRITES/100)),2);case"both":return roundNumber((DISKS*(Calc_SequentialWriteIO()+Calc_RandomWriteIO())/2)/(RAID_LEVEL*(1+((IO_SIZE*1/DISK_SECTOR_SIZE)-1)/(STRIPE_SIZE*1/DISK_SECTOR_SIZE))*(1-CACHE_HIT_RATIO_WRITES/100)),2);}break;case"both":switch(IO_PATTERN.toLowerCase()){case"random":return roundNumber((DISKS*((Calc_RandomReadIO()+Calc_RandomWriteIO())/2))/((1+((IO_SIZE*1/DISK_SECTOR_SIZE)-1)/(STRIPE_SIZE*1/DISK_SECTOR_SIZE))*PERCENT_READS/100*(1-CACHE_HIT_RATIO_READS/100)+RAID_LEVEL*(1+((IO_SIZE*1/DISK_SECTOR_SIZE)-1)/(STRIPE_SIZE*1/DISK_SECTOR_SIZE))*PERCENT_WRITES/100*(1-CACHE_HIT_RATIO_WRITES/100)),2);case"sequential":return roundNumber((DISKS*(Calc_SequentialReadIO()+Calc_SequentialWriteIO())/2)/((1+((IO_SIZE*1/DISK_SECTOR_SIZE)-1)/(STRIPE_SIZE*1/DISK_SECTOR_SIZE))*PERCENT_READS/100*(1-CACHE_HIT_RATIO_READS/100)+RAID_LEVEL*(1+((IO_SIZE*1/DISK_SECTOR_SIZE)-1)/(STRIPE_SIZE*1/DISK_SECTOR_SIZE))*PERCENT_WRITES/100*(1-CACHE_HIT_RATIO_WRITES/100)),2);case"both":return roundNumber((DISKS*(Calc_SequentialReadIO()+Calc_SequentialWriteIO()+Calc_RandomReadIO()+Calc_RandomWriteIO())/4)/((1+((IO_SIZE*1/DISK_SECTOR_SIZE)-1)/(STRIPE_SIZE*1/DISK_SECTOR_SIZE))*PERCENT_READS/100*(1-CACHE_HIT_RATIO_READS/100)+RAID_LEVEL*(1+((IO_SIZE*1/DISK_SECTOR_SIZE)-1)/(STRIPE_SIZE*1/DISK_SECTOR_SIZE))*PERCENT_WRITES/100*(1-CACHE_HIT_RATIO_WRITES/100)),2);}}}function Avg_MBSec(){return roundNumber(Avg_IOPs()*IO_SIZE/1024,2);}function get_DiskThroughputMBSecIOSize(){switch(IO_TYPE.toLowerCase()){case"read":switch(IO_PATTERN.toLowerCase()){case"random":return roundNumber((IO_SIZE*Calc_RandomReadIO())/1024,2).toFixed(2);case"sequential":return roundNumber((IO_SIZE*Calc_SequentialReadIO())/1024,2).toFixed(2);case"both":return roundNumber((IO_SIZE*(Calc_RandomReadIO()+Calc_SequentialReadIO())/2)/1024,2).toFixed(2);}break;case"write":switch(IO_PATTERN.toLowerCase()){case"random":return roundNumber((IO_SIZE*Calc_RandomWriteIO())/1024,2).toFixed(2);case"sequential":return roundNumber((IO_SIZE*Calc_SequentialWriteIO())/1024,2).toFixed(2);case"both":return roundNumber((IO_SIZE*(Calc_RandomWriteIO()+Calc_SequentialWriteIO())/2)/1024,2).toFixed(2);}break;case"both":switch(IO_PATTERN.toLowerCase()){case"random":return roundNumber((IO_SIZE*(Calc_RandomWriteIO()+Calc_RandomReadIO()/2))/1024,2).toFixed(2);case"sequential":return roundNumber((IO_SIZE*(Calc_SequentialWriteIO()+Calc_SequentialReadIO()/2))/1024,2).toFixed(2);case"both":return roundNumber((IO_SIZE*(Calc_RandomWriteIO()+Calc_SequentialWriteIO()+Calc_RandomReadIO()+Calc_SequentialReadIO())/4)/1024,2).toFixed(2);}}}function get_DiskThroughputMBSecSectorSize(){switch(IO_TYPE.toLowerCase()){case"read":switch(IO_PATTERN.toLowerCase()){case"random":return roundNumber((DISK_SECTOR_SIZE*Calc_RandomReadIO()),2).toFixed(2);case"sequential":return roundNumber((DISK_SECTOR_SIZE*Calc_SequentialReadIO()),2).toFixed(2);case"both":return roundNumber((DISK_SECTOR_SIZE*(Calc_RandomReadIO()+Calc_SequentialReadIO())/2),2).toFixed(2);}break;case"write":switch(IO_PATTERN.toLowerCase()){case"random":return roundNumber((DISK_SECTOR_SIZE*Calc_RandomWriteIO()),2).toFixed(2);case"sequential":return roundNumber((DISK_SECTOR_SIZE*Calc_SequentialWriteIO()),2).toFixed(2);case"both":return roundNumber((DISK_SECTOR_SIZE*(Calc_RandomWriteIO()+Calc_SequentialWriteIO())/2),2).toFixed(2);}break;case"both":switch(IO_PATTERN.toLowerCase()){case"random":return roundNumber((DISK_SECTOR_SIZE*(Calc_RandomWriteIO()+Calc_RandomReadIO()/2))/1024,2).toFixed(2);case"sequential":return roundNumber((DISK_SECTOR_SIZE*(Calc_SequentialWriteIO()+Calc_SequentialReadIO()/2))/1024,2).toFixed(2);case"both":return roundNumber((DISK_SECTOR_SIZE*(Calc_RandomWriteIO()+Calc_SequentialWriteIO()+Calc_RandomReadIO()+Calc_SequentialReadIO())/4)/1024,2).toFixed(2);}}}function get_RAIDLevelStripe(){switch(RAID_LEVEL){case 1:return"Estimated Stripe Size RAID 0 Unknown Concurrency:";case 2:return"Estimated Stripe Size RAID 10 Unknown Concurrency:";case 4:return"Estimated Stripe Size RAID 5 Unknown Concurrency:";case 6:return"Estimated Stripe Size RAID 6 Unknown Concurrency:";}}function Next_Block_Multiple(input_size){if(input_size<4){return 4;}else if(input_size<8){return 8;}else if(input_size<16){return 16;}else if(input_size<32){return 32;}else if(input_size<64){return 64;}else if(input_size<128){return 128;}else if(input_size<256){return 256;}else if(input_size<512){return 512;}else if(input_size<1024){return 1024;}else if(input_size<2048){return 2048;}else if(input_size<4096){return 4096;}else if(input_size>4096){return 4096;}}function Estimated_Array_Capacity(){switch(RAID_LEVEL){case 1:return DISKS*DISK_CAPACITY;case 2:return DISKS/2*DISK_CAPACITY;case 4:return(DISKS-1)*DISK_CAPACITY;case 6:return(DISKS-2)*DISK_CAPACITY;}}function Estimated_Stipe_Size_Unkown_Concurrency(){switch(RAID_LEVEL){case 1:return Next_Block_Multiple((2/3*RANDOM_SEEK_WRITE*(MIN_MB_PER_SEC+MAX_MB_PER_SEC)/2));case 2:return Next_Block_Multiple((2/3*RANDOM_SEEK_WRITE*(MIN_MB_PER_SEC+MAX_MB_PER_SEC)/2));case 4:return Next_Block_Multiple((0.5*RANDOM_SEEK_WRITE*(MIN_MB_PER_SEC+MAX_MB_PER_SEC)/2));case 6:return Next_Block_Multiple((0.75*RANDOM_SEEK_WRITE*(MIN_MB_PER_SEC+MAX_MB_PER_SEC)/2));}}function Estimated_Stripe_Size_Raid_10_Known_Conncurency(){return(Next_Block_Multiple(((0.25*RANDOM_SEEK_WRITE*(MIN_MB_PER_SEC+MAX_MB_PER_SEC)/2*(CONCURRENT_USERS-1)*1.024)+5)));}function Estimated_Number_Of_Drives_For_IO(){return roundNumber((TARGET_IOS/(Avg_IOPs()/DISKS)),0);}function Estimated_Number_Of_Drives_For_MBSec(){return roundNumber(TARGET_MBSEC/(Avg_MBSec()/DISKS),0);}function Minimum_Number_Of_Drives_RAID(estnumdrives){switch(RAID_LEVEL){case 1:if(estnumdrives<1){return 1;}else{return estnumdrives;}break;case 2:if(estnumdrives<4){return 4;}else if(estnumdrives%2===0){return estnumdrives;}else{return estnumdrives+1;}break;case 4:if(estnumdrives<3){return 3;}else{return estnumdrives;}break;case 6:if(estnumdrives<4){return 4;}else{return estnumdrives;}}}function Calculate(){DISK_CHOICE=document.getElementById("diskchoice").value.toInt();if(DISK_CHOICE===0){}else{try{document.getElementById("sectorsize").value=DiskDrives.spec[DISK_CHOICE].sectorsize;document.getElementById("rpm").value=DiskDrives.spec[DISK_CHOICE].rpm;document.getElementById("sequentialseekread").value=DiskDrives.spec[DISK_CHOICE].sequentialseekread;document.getElementById("sequentialseekwrite").value=DiskDrives.spec[DISK_CHOICE].sequentialseekwrite;document.getElementById("randomseekread").value=DiskDrives.spec[DISK_CHOICE].randomseekread;document.getElementById("randomseekwrite").value=DiskDrives.spec[DISK_CHOICE].randomseekwrite;document.getElementById("rotationallatency").value=DiskDrives.spec[DISK_CHOICE].rotationallatency;document.getElementById("sizeinmb").value=DiskDrives.spec[DISK_CHOICE].sizeinmb;document.getElementById("minmbpersecond").value=DiskDrives.spec[DISK_CHOICE].minmbpersecond;document.getElementById("maxmbpersecond").value=DiskDrives.spec[DISK_CHOICE].maxmbpersecond;document.getElementById("diskname").value=DiskDrives.spec[DISK_CHOICE].diskname;}catch(err){txt="There was an error on this page.\n\n";txt+="Error description: "+err.description+"\n\n";document.writeln(txt);}}DISK_SECTOR_SIZE=document.getElementById("sectorsize").value.toFloat();RPM=document.getElementById("rpm").value.toFloat();SEQUENTIAL_SEEK_READ=document.getElementById("sequentialseekread").value.toFloat();SEQUENTIAL_SEEK_WRITE=document.getElementById("sequentialseekwrite").value.toFloat();RANDOM_SEEK_READ=document.getElementById("randomseekread").value.toFloat();RANDOM_SEEK_WRITE=document.getElementById("randomseekwrite").value.toFloat();ROTATIONAL_LATENCY=document.getElementById("rotationallatency").value.toFloat();MIN_MB_PER_SEC=document.getElementById("minmbpersecond").value.toFloat();MAX_MB_PER_SEC=document.getElementById("maxmbpersecond").value.toFloat();DISK_CAPACITY=document.getElementById("sizeinmb").value;DISK_CAPACITY=DISK_CAPACITY.replace("GB","");TARGET_MBSEC=document.getElementById("targetmbsec").value.toFloat();TARGET_IOS=document.getElementById("targetios").value.toFloat();IO_SIZE=document.getElementById("iosize").value.toFloat();STRIPE_SIZE=document.getElementById("stripesize").value.toFloat();RAID_LEVEL=document.getElementById("raidlevel").value.toFloat();CONCURRENT_USERS=document.getElementById("concurrentusers").value.toFloat();PERCENT_READS=document.getElementById("precentreads").value.toFloat();PERCENT_WRITES=document.getElementById("precentwrites").value.toFloat();IO_TYPE=document.getElementById("iotype").value.toString();IO_PATTERN=document.getElementById("iopattern").value.toString();try{DISKS=Minimum_Number_Of_Drives_RAID(document.getElementById("disks").value);document.getElementById("disks").value=Minimum_Number_Of_Drives_RAID(document.getElementById("disks").value);}catch(err2){txt="There was an error on this page.\n\n";txt+="Error description: "+err2.description+"\n\n";document.writeln(txt);}if(document.getElementById("cachehitratioreads").value.toFloat()>=100){CACHE_HIT_RATIO_READS=99;}else{CACHE_HIT_RATIO_READS=document.getElementById("cachehitratioreads").value.toFloat();}if(document.getElementById("cachehitratiowrites").value.toFloat()>=100){CACHE_HIT_RATIO_WRITES=99;}else{CACHE_HIT_RATIO_WRITES=document.getElementById("cachehitratiowrites").value.toFloat();}Write("out_targetio","Drives Needed for "+TARGET_IOS+" IO/Sec");Write("out_targetmbsec","Drives Needed for "+TARGET_MBSEC+" MB/Sec");Write("out_sequentialreadio",pad_with_zeros(Calc_SequentialReadIO(),2));Write("out_randomreadio",pad_with_zeros(Calc_RandomReadIO(),2));Write("out_sequentialwriteio",pad_with_zeros(Calc_SequentialWriteIO(),2));Write("out_randomwriteio",pad_with_zeros(Calc_RandomWriteIO(),2));Write("out_Avg_IOPs",pad_with_zeros(Avg_IOPs(),2));Write("out_Avg_MBSec",pad_with_zeros(Avg_MBSec(),2));Write("out_io_pattern_type",Get_IOTypeValues());Write("out_io_pattern_type_mbsec",Get_IOTypeValuesMBSec());Write("out_io_pattern_type_mbsec_iosize",Get_IOTypeValuesMBSecIOSize());Write("out_io_pattern_type_mbsec_sectorsize",Get_IOTypeValuesMBSecSectorSize());Write("out_raidlevelstripe",get_RAIDLevelStripe());Write("out_Disk_Throughput_SectorSize_MBSec",get_DiskThroughputMBSecSectorSize());Write("out_Disk_Throughput_IOSize_MBSec",get_DiskThroughputMBSecIOSize());Write("out_Estimated_Stripe_Size_Unknown_Concurrency",Estimated_Stipe_Size_Unkown_Concurrency());Write("out_Estimated_Stripe_Size_Raid_10_Known_Conncurency",Estimated_Stripe_Size_Raid_10_Known_Conncurency());Write("out_Estimated_Number_Of_Drives_For_IO",Minimum_Number_Of_Drives_RAID(Estimated_Number_Of_Drives_For_IO()));Write("out_Estimated_Number_Of_Drives_For_MBSec",Minimum_Number_Of_Drives_RAID(Estimated_Number_Of_Drives_For_MBSec()));Write("out_raid_capacity",Get_OutRaidCapacity());Write("out_capacity",pad_with_zeros(Estimated_Array_Capacity(),2));}function init(){document.getElementById(INITIAL_ELEMENT_ID_TO_FOCUS).focus();Calculate();}