예제 #1
0
 public bool CheckHash()
 {
     return(Hash == (CellsForSerialize.GetHashCode() ^ UsedTime.GetHashCode()));
 }
예제 #2
0
파일: Program.cs 프로젝트: qiuhy/zj
        public static int zjAnalyze(IEnumerable <Bill> billList)
        {
            int billListCount = billList.Count();

            if (billListCount == 0)
            {
                Console.WriteLine("无数据,退出");
                return(0);
            }
            Logger logger = new Logger(logLevel: System.Diagnostics.SourceLevels.Information);

            IEnumerable <Bill> inBills, outBills;
            UsedTime           ut = new UsedTime();

            int  totalInMatched  = 0;
            int  totalOutMatched = 0;
            long totalMatchCount = 0;
            long curMatchCount   = 0;

            void showMatchResult(List <Match> result, long matchCount, double progress)
            {
                if (matchCount == 0)
                {
                    return;
                }
                curMatchCount += matchCount;
                if (result.Count > 0)
                {
                    logger.verbose(result[0]);
                }

                Console.SetCursorPosition(0, Console.CursorTop);
                Console.Write($"{DateTime.Now:HH:mm:ss} {matchCount,10} {curMatchCount,12} {progress,7:p2}");
                Console.SetCursorPosition(0, Console.CursorTop);
            };

            Analyze a         = new Analyze(showMatchResult);
            string  strFormat = "{0} matched: {1,5} ({2,3},{3,3}) used time:{4,-7:f3} count:{5,-10} speed:{6,10:f2}/s";

            void doMatch(string name, double deviation, int dateRange, int inLevel, int outLevel)
            {
                curMatchCount = 0;
                ut.Add(name);
                int[] matched;
                // logger.info($"{name} maxDeviation:{maxDeviation} maxDateRange:{maxDateRange}");
                if ("Day".Equals(name))
                {
                    matched = a.Match_Day(inBills, outBills, deviation, dateRange, inLevel, outLevel);
                }
                else
                {
                    matched = a.Match_MvM(inBills, outBills, deviation, dateRange, inLevel, outLevel);
                }

                totalInMatched  += matched[0];
                totalOutMatched += matched[1];
                totalMatchCount += curMatchCount;
                logger.info(strFormat, name
                            , matched[0] + matched[1]
                            , matched[0]
                            , matched[1]
                            , ut.GetElapse(name).TotalSeconds
                            , StringUtil.Number2Str(curMatchCount)
                            , StringUtil.Number2Str(curMatchCount / ut.GetElapse(name).TotalSeconds, 2));
            }

            logger.info("Start 开始");

            inBills = billList.Where(x => x.isOut == false)
                      .OrderBy(x => x.date).ThenBy(x => x.id)
                      .ToList();
            outBills = billList.Where(x => x.isOut == true)
                       .OrderBy(x => x.date).ThenBy(x => x.id)
                       .ToList();

            int inBillsCount  = inBills.Count();
            int outBillsCount = outBills.Count();

            logger.info($"Bills:{billListCount}  ({inBillsCount} ,{outBillsCount})");

            double maxDeviation = 0.001;
            int    maxDateRange = 2;

            // doMatch("5v5", 0.001, 1, 5, 5);
            doMatch("1v1", maxDeviation, maxDateRange, 1, 1);
            doMatch($"Day", maxDeviation, maxDateRange, 0, 0);
            for (int i = 2; i <= 5; i++)
            {
                doMatch($"1v{i}", maxDeviation, maxDateRange, 1, i);
                doMatch($"{i}v1", maxDeviation, maxDateRange, i, 1);
            }
            for (int i = 2; i <= 5; i++)
            {
                for (int j = 2; j <= 5; j++)
                {
                    doMatch($"{i}v{j}", maxDeviation, maxDateRange, i, j);
                }
            }

            logger.info(new String('-', 80));
            logger.info($"SUM match(%) {(double)(totalInMatched + totalOutMatched) / (inBillsCount + outBillsCount),6:p2}"
                        + $"({(double)totalInMatched / inBillsCount:p2}, {(double)totalOutMatched / outBillsCount:p2})");
            logger.info(strFormat, "SUM"
                        , totalInMatched + totalOutMatched
                        , totalInMatched
                        , totalOutMatched
                        , ut.GetElapse().TotalSeconds
                        , StringUtil.Number2Str(totalMatchCount)
                        , StringUtil.Number2Str(totalMatchCount / ut.GetElapse().TotalSeconds, 2));


            return(totalInMatched + totalOutMatched);
        }