public void Analyze(long max_duration_in_ms)
{
var sw = new System.Diagnostics.Stopwatch();
sw.Start();
using (var pb = new ProgBar())
{
// Disable screen updating during analysis to speed things up
_app.ScreenUpdating = false;
// Build dependency graph (modifies data)
try
{
_dag = new DAG(_app.ActiveWorkbook, _app, IGNORE_PARSE_ERRORS);
var num_input_cells = _dag.numberOfInputCells();
}
catch (ExcelParserUtility.ParseException e)
{
// cleanup UI and then rethrow
_app.ScreenUpdating = true;
throw e;
}
if (_dag.terminalInputVectors().Length == 0)
{
System.Windows.Forms.MessageBox.Show("This spreadsheet contains no vector-input functions.");
_app.ScreenUpdating = true;
_flaggable = new KeyValuePair<AST.Address, int>[0];
return;
}
// Get bootstraps
var scores = Analysis.DataDebug(NBOOTS,
_dag,
_app,
weighted: USE_WEIGHTS,
all_outputs: CONSIDER_ALL_OUTPUTS,
max_duration_in_ms: max_duration_in_ms,
sw: sw,
significance: _tool_significance,
pb: pb)
.OrderByDescending(pair => pair.Value).ToArray();
if (_debug_mode)
{
var score_str = String.Join("\n", scores.Take(10).Select(score => score.Key.A1FullyQualified() + " -> " + score.Value.ToString()));
System.Windows.Forms.MessageBox.Show(score_str);
System.Windows.Forms.Clipboard.SetText(score_str);
}
List<KeyValuePair<AST.Address, int>> high_scores = new List<KeyValuePair<AST.Address, int>>();
// calculate cutoff idnex
int thresh = scores.Length - Convert.ToInt32(scores.Length * _tool_significance);
// filter out cells that are...
_flaggable = scores.Where(pair => pair.Value >= scores[thresh].Value) // below threshold
.Where(pair => !_known_good.Contains(pair.Key)) // known to be good
.Where(pair => pair.Value != 0).ToArray(); // score == 0
// Enable screen updating when we're done
_app.ScreenUpdating = true;
sw.Stop();
}
}