예제 #1
0
        private static void Main(string[] args)
        {
            var preludeFileName = args[0];
            var preludeScript   = File.ReadAllText(preludeFileName);
            var queryFileName   = args[1];
            var queryScript     = File.ReadAllText(queryFileName);

            Func <string, Tuple <string, string> > loadModule =
                moduleName =>
            {
                var moduleFilename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, moduleName + ".js");
                return
                    (Tuple.Create(
                         File.ReadAllText(moduleFilename),
                         moduleFilename));
            };

            using (var prelude = new PreludeScript(preludeScript, preludeFileName, loadModule))
                using (var query = new QueryScript(prelude, queryScript, queryFileName))
                    using (var events = File.OpenText(args[2]))
                        using (var output = (args.Length >= 4) ? File.CreateText(args[3]) : Console.Out)
                        {
                            long totalMs = 0;
                            int  count   = 0;
                            query.Initialize();
                            if (output != null)
                            {
                                var capturedOutput = output;
                                query.Emit += s => capturedOutput.WriteLine(s.Trim());
                            }
                            var sw = new Stopwatch();
                            while (!events.EndOfStream)
                            {
                                var eventJson = events.ReadLine().Trim();
                                if (!string.IsNullOrWhiteSpace(eventJson))
                                {
                                    sw.Start();
                                    query.Push(eventJson, null);
                                    count++;
                                    sw.Stop();
                                }
                            }
                            totalMs = sw.ElapsedMilliseconds;
                            Console.WriteLine(query.GetState());
                            Console.WriteLine(query.GetStatistics());
                            Console.WriteLine("Total JS push processing time: {0,5:f2} ms", totalMs);
                            Console.WriteLine("Average time per 1000 pushes:  {0,5:f2} ms", 1000f * totalMs / (float)count);
                            Console.WriteLine("Pure JS events per second:     {0,5:f2} events", count * 1000f / totalMs);
                            Console.WriteLine("Total events processed:        {0} events", count);
                        }
        }
예제 #2
0
 public void Initialize()
 {
     _query.Initialize();
 }
예제 #3
0
 public void Initialize()
 {
     CheckDisposed();
     _query.Initialize();
 }