function FloatToString(nValue, nSigns)
{
  var nPow = Math.round(Math.pow(10, nSigns));

  return "" + Math.round(nValue * nPow) / nPow;
}

function SmartFloatToString(nValue, nSigns)
{
  if (nValue < 100)
    nSigns++;

  if (nValue < 10)
    nSigns++;

  if (nValue < 1)
    nSigns++;

  return FloatToString(nValue, nSigns);
}

function TestInfo(name, nodeName, coef, unit)
{
  this.m_name = name;
  this.m_nodeName = nodeName;
  this.m_coef = coef;
  this.m_unit = unit;
  this.m_std = 0; // for iPAQ 3600
  this.m_pIndex = null;
}

// file sizes
var PW_SIZE = 266760;
var PIE_HTML_SIZE = 25347;
var PIE_JPEG_SIZE = 259525;
var ZIP_SIZE = 1037080;
var JPEG_SIZE = 287880;

function Size2Coef(size)
{
  return size * 1000.0 / 1024;
}

// k ms                   Mop
// ----- => N * 0.001 / k ---
// N op                   sec

var n4 = 210*100;
var n8 = 93*100;

function MFLOPSCoef()
{
  var xtra = 10;
  var n = 4;

  return n8 / 100 * n * xtra * 0.1;
}

function MOPSCoef()
{
  var xtra = 200;
  var n = 15;

  return n4 / 100 * n * xtra * 0.1;
}

function MWIPSCoef()
{
  var xtra = 5;

  return xtra * 100 * 100.0;
}

var g_pMainTests = new Array(
  new TestInfo("Write 1 MB file", "fs-largefilewrite", 1024000, "KB/sec"),
  new TestInfo("Read 1 MB file", "fs-largefileread", 1000, "MB/sec"),
  new TestInfo("Copy 1 MB file", "fs-largefilecopy", 1024000, "KB/sec"),
  new TestInfo("Write 10 KB x 100 files", "fs-manyfileswrite", 1024000, "KB/sec"),
  new TestInfo("Read 10 KB x 100 files", "fs-manyfilesread", 1000, "MB/sec"),
  new TestInfo("Copy 10 KB x 100 files", "fs-manyfilescopy", 1024000, "KB/sec"),
  new TestInfo("Directory list of 2000 files", "fs-dirlisting", 2000, "thousands of files/sec"),
  new TestInfo("Internal database read", "fs-db", 1000000, "records/sec"),
  new TestInfo("Graphics test: DDB BitBlt", "grf-ddb", 1000, "frames/sec"),
  new TestInfo("Graphics test: DIB BitBlt", "grf-dib", 1000, "frames/sec"),
  new TestInfo("Graphics test: GAPI BitBlt", "grf-gapi", 1000, "frames/sec"),
  new TestInfo("Pocket Word document open", "builtin-pw", Size2Coef(PW_SIZE), "KB/sec"),
  new TestInfo("Pocket Internet Explorer HTML load", "builtin-pie-html", Size2Coef(PIE_HTML_SIZE), "KB/sec"),
  new TestInfo("Pocket Internet Explorer JPEG load", "builtin-pie-jpeg", Size2Coef(PIE_JPEG_SIZE), "KB/sec"),
  new TestInfo("File Explorer large folder list", "builtin-fe", 2000000, "files/sec"),
  new TestInfo("Compress 1 MB file using ZIP", "misc-zip", Size2Coef(ZIP_SIZE), "KB/sec"),
  new TestInfo("Decompress 1024x768 JPEG file", "misc-jpeg", Size2Coef(JPEG_SIZE), "KB/sec"),
  new TestInfo("Arkaball frames per second", "misc-arkaball", 1000, "frames/sec"),
  new TestInfo("CPU test: Whetstones MFLOPS", "misc-mflops", MFLOPSCoef(), "Mop/sec"),
  new TestInfo("CPU test: Whetstones MOPS", "misc-mops", MOPSCoef(), "Mop/sec"),
  new TestInfo("CPU test: Whetstones MWIPS", "misc-mwips", MWIPSCoef(), "Mop/sec"),
  new TestInfo("Memory test: copy 1 MB using memcpy", "misc-memcpy", 1000, "MB/sec"),
  new TestInfo("ActiveSync: upload 1 MB file", "acs-write", 1024000, "KB/sec"),
  new TestInfo("ActiveSync: download 1 MB file", "acs-read", 1024000, "KB/sec")
);

var g_pStorageCardTests = new Array(
  new TestInfo("Writing 1 MB file", "sc-largefilewrite", 1024000, "KB/sec"),
  new TestInfo("Reading 1 MB file", "sc-largefileread", 1000, "MB/sec"),
  new TestInfo("Copying 1 MB file to storage card", "sc-largefilecopyto", 1024000, "KB/sec"),
  new TestInfo("Copying 1 MB file from storage card", "sc-largefilecopyfrom", 1024000, "KB/sec"),
  new TestInfo("Writing 100 of 10 KB files", "sc-manyfileswrite", 1024000, "KB/sec"),
  new TestInfo("Reading 100 of 10 KB files", "sc-manyfilesread", 1000, "MB/sec"),
  new TestInfo("Copying 100 of 10 KB files to storage card", "sc-manyfilescopyto", 1024000, "KB/sec"),
  new TestInfo("Copying 100 of 10 KB files from storage card", "sc-manyfilescopyfrom", 1024000, "KB/sec"),
  new TestInfo("Directory listing: 2000 files", "sc-dirlisting", 2000, "thousands of files/sec")
);

var g_pBatteryTestsList = new Array(
  new TestInfo("No backlight, no using", "bat-nobklnousing"),
  new TestInfo("Max backlight, video playback", "bat-maxbklvideo"),
  new TestInfo("No display, mp3 playback", "bat-nodsplmp3"),
  new TestInfo("Max backlight, standard using", "bat-maxbklstdusing"),
  new TestInfo("Max backlight, GPRS", "bat-maxbklgrps"),
  new TestInfo("Max backlight, Bluetooth", "bat-maxbklbluetooth"),
  new TestInfo("Max backlight, WiFi", "bat-maxbklwifi")
);

