Beispiel #1
0
        static Metric()
        {
            var time       = new Func <double, string> (d => String.Format("{0:N0}", SqliteUtils.FromDbFormat(typeof(DateTime), d)));
            var duration   = new Func <double, string> (d => String.Format("{0:N0}", TimeSpan.FromMilliseconds(d)));
            var duration_s = new Func <double, string> (d => String.Format("{0:N0}", TimeSpan.FromSeconds(d)));
            var px         = new Func <double, string> (d => String.Format("{0:N0} px", d));

            Add(
                "/AvgBitRate", new Func <double, string> (d => String.Format("{0:N0} kbps", d)),
                "/AvgScore",
                "/BpmTrackCount",
                "/ComposerTrackCount",
                "/ErrorTrackCount",
                "/GroupingTrackCount",
                "/LicenseUriTrackCount",
                "/RatedTrackCount",
                "/TotalFileSize", new Func <double, string> (d => new FileSizeQueryValue((long)d).ToUserQuery()),
                "/TotalPlayCount",
                "/TotalPlaySeconds", duration_s,
                "/TotalSkipCount",
                "/TrackCount",
                "/UnplayedTrackCount",

                "Banshee/BuildTime", time,
                "Banshee/Configuration/browser/position", px,

                "Banshee/Configuration/player_window/height", px,
                "Banshee/Configuration/player_window/source_view_row_height", px,
                "Banshee/Configuration/player_window/source_view_row_padding", px,
                "Banshee/Configuration/player_window/source_view_width", px,
                "Banshee/Configuration/player_window/width", px,

                "Banshee/Configuration/player_window/x_pos",
                "Banshee/Configuration/player_window/y_pos",

                "Banshee/Configuration/plugins.mtp/albumart_max_width", px,

                "Banshee/Configuration/plugins.play_queue/played_songs_number",
                "Banshee/Configuration/plugins.play_queue/upcoming_songs_number",

                "Banshee/Display/NScreens",

                "Banshee/Screen/Height", px,
                "Banshee/Screen/Width", px,
                "Banshee/Screen/NMonitors",
                "Banshee/ShutdownAt", time,
                "Banshee/StartedAt", time,
                "Env/Processor Count",

                "Banshee/RunDuration", duration
                );
        }
Beispiel #2
0
        public override void Step(object[] args, int stepNumber, ref object contextData)
        {
            List <T> list = null;

            if (contextData == null)
            {
                contextData = list = new List <T> ();
            }
            else
            {
                list = contextData as List <T>;
            }

            var val = (T)SqliteUtils.FromDbFormat(typeof(T), args[0]);

            list.Add(val);
        }
Beispiel #3
0
        public MetaMetrics(Database db)
        {
            var latest_samples = new SampleModel("GROUP BY UserID, MetricID ORDER BY stamp desc", db, "COUNT(DISTINCT(UserID)), MIN(Stamp), MAX(Stamp)");

            latest_samples.Cache.AggregatesUpdated += (reader) => {
                Console.WriteLine("Total unique users for this time slice: {0}", reader[1]);
                Console.WriteLine("First report was on {0}", SqliteUtils.FromDbFormat(typeof(DateTime), reader[2]));
                Console.WriteLine("Last report was on {0}", SqliteUtils.FromDbFormat(typeof(DateTime), reader[3]));
                Console.WriteLine();
            };
            latest_samples.Reload();

            var string_summary = new MetricSampleModel(latest_samples.Cache, db,
                                                       @"COUNT(DISTINCT(UserID))"
                                                       );

            string_summary.Cache.AggregatesUpdated += (agg_reader) => {
                Console.WriteLine(String.Format("   Users:  {0}", fmt), agg_reader[1]);
                using (var reader = new HyenaDataReader(db.Query(
                                                            @"SELECT COUNT(DISTINCT(UserId)) as users, Value FROM Samples, HyenaCache
                        WHERE MetricId = ? AND HyenaCache.ModelID = ? AND HyenaCache.ItemID = Samples.ID
                        GROUP BY Value ORDER BY users DESC", string_summary.MetricId, string_summary.Cache.CacheId))) {
                    while (reader.Read())
                    {
                        Console.WriteLine("   {0,-5}: {1,-20}", reader.Get <long> (0), reader.Get <string> (1));
                    }
                }
                Console.WriteLine();
            };

            var numeric_slice = new MetricSampleModel(latest_samples.Cache, db,
                                                      @"MIN(CAST(Value as NUMERIC)), MAX(CAST(Value as NUMERIC)),
                  AVG(CAST(Value as NUMERIC)), HYENA_METRICS_MEDIAN_DOUBLE(CAST(Value as NUMERIC)), COUNT(DISTINCT(UserID))"
                                                      );

            numeric_slice.Cache.AggregatesUpdated += (reader) => {
                Console.WriteLine(String.Format("   Users:  {0}", fmt), reader[5]);
                Console.WriteLine(String.Format("   Min:    {0}", fmt), Metric.ToString(numeric_slice.MetricName, reader[1]));
                Console.WriteLine(String.Format("   Avg:    {0}", fmt), Metric.ToString(numeric_slice.MetricName, reader[3]));
                Console.WriteLine(String.Format("   Median: {0}", fmt), Metric.ToString(numeric_slice.MetricName, reader[4]));
                Console.WriteLine(String.Format("   Max:    {0}", fmt), Metric.ToString(numeric_slice.MetricName, reader[2]));
                Console.WriteLine();
            };

            var metrics = db.QueryEnumerable <string> ("SELECT Name FROM Metrics ORDER BY Name ASC");

            foreach (var metric in metrics)
            {
                switch (GetMetricType(metric))
                {
                case "string":
                    Console.WriteLine("{0}:", metric);
                    string_summary.ChangeMetric(db, metric);
                    break;

                //case "timespan" : SummarizeNumeric<TimeSpan> (metric); break;
                //case "datetime" : SummarizeNumeric<DateTime> (metric); break;
                case "float":
                    Console.WriteLine("{0}:", metric);
                    //SummarizeNumeric<long> (metric_cache);
                    numeric_slice.ChangeMetric(db, metric);
                    break;
                    //case "float":
                    //SummarizeNumeric<double> (metric_cache);
                    //break;
                }
            }
        }