Beispiel #1
0
 /// <summary>
 /// Stops the timer and adds a specified timing point type to th timings list
 /// </summary>
 /// <param name="timerType"></param>
 /// <returns></returns>
 public TimeSpan StopTimer(EnumTiming timerType)
 {
     try
     {
         CurrentTimer.Stop();
         Timings.Add(new Tuple <EnumTiming, RatTimer>(timerType, CurrentTimer));
         return(CurrentTimer.Duration);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Unable to stop the timer");
         Console.WriteLine(ex.Message);
         return(new TimeSpan(0));
     }
 }
        public override string ToString()
        {
            timer.Restart();
            var    temp = ScoreByDay;
            string str  =
                "~ ------------------- ~\r\n" +
                "~ --- BY HOUR/DAY --- ~\r\n" +
                "~ ------------------- ~\r\n" +
                String.Join(
                    "\r\n",
                    ScoreByHourByDay.Select(
                        d => new KeyValuePair <KeyValuePair <DayOfWeek, double>, SortedDictionary <int, double> >(
                            new KeyValuePair <DayOfWeek, double>(
                                d.Key, temp[d.Key]
                                ), d.Value
                            )
                        ).OrderByDescending(d => d.Key.Value).Take(5).Select(
                        d => String.Format(
                            DAY_FORMAT,
                            d.Key.Key,
                            d.Key.Value,
                            String.Join(
                                "\r\n",
                                d.Value.OrderByDescending(h => h.Value).Take(3).Select(
                                    h => "\t" + h.Key.ToString() + " - " + h.Value.ToString("#.000")
                                    )
                                )
                            )
                        )
                    ) +
                "\r\n\r\n" +
                "~ ----------------------- ~\r\n" +
                "~ --- BY HOUR AND DAY --- ~\r\n" +
                "~ ----------------------- ~\r\n" +
                String.Join(
                    "\r\n",
                    ScoreByHourAndDay.OrderByDescending(kv => kv.Value).Take(15).Select(
                        kv => kv.Key.Key.ToString() + "\t - \t" + kv.Key.Value.ToString() + ": \t" + kv.Value.ToString("#.000")
                        )
                    );

            timer.Stop();
            temp = null;
            Timings.Add(new KeyValuePair <string, long>("ToString", timer.ElapsedMilliseconds));
            return(str);
        }