public void ToDictionaryTest() { var xs = Observable.Interval(TimeSpan.FromSeconds(0.1)) .Take(100); xs = xs.Monitor("A", 1); var zs = from w in xs.Window(10) from lookups in w.ToDictionary <long, string>(i => (i).ToString()) select lookups; #region zs = zs.Monitor("ToDictionary",...) var surrogate = new MonitorSurrogate <IDictionary <string, long> >( (lookup, marble) => { StringBuilder sb = new StringBuilder(); foreach (KeyValuePair <string, long> pair in lookup) { sb.AppendFormat("{0}: {1}\r\n", pair.Key, pair.Value); } return(sb.ToString()); }); zs = zs.Monitor("ToDictionary", 1, surrogate); #endregion zs = zs.Monitor("ToDictionary",...) zs.Wait(); }
public void WindowAggregationTest() { IObservable <long> xs = Observable.Interval(TimeSpan.FromSeconds(0.01)) .Take(300); #region Monitor xs = xs.Monitor("Source", 1); #endregion Monitor IObservable <IObservable <long> > ws = xs.Window(TimeSpan.FromSeconds(2)); #region Monitor ws = ws.MonitorMany("Win", 2); #endregion Monitor IObservable <OHLC> aggs = from win in ws from acc in win.Aggregate(new OHLC(), OHLC.Accumulate) select acc; #region Monitor var surrogate = new MonitorSurrogate <OHLC>( (holc, marble) => string.Format("Open = {0}, Close = {1}, High = {2}, Low = {3}", holc.Open, holc.Close, holc.High, holc.Low)); aggs = aggs.Monitor("Accumulate", 3, surrogate); #endregion Monitor aggs.Wait(); }
public void LookupTest() { var xs = Observable.Interval(TimeSpan.FromSeconds(0.1)) .Take(100); xs = xs.Monitor("A", 1); var zs = from w in xs.Window(10) from lookups in w.ToLookup <long, string>(i => (i % 4).ToString()) select lookups; #region zs = zs.Monitor("Lookup",...) var surrogate = new MonitorSurrogate <ILookup <string, long> >( (lookup, marble) => { StringBuilder sb = new StringBuilder(); foreach (IGrouping <string, long> g in lookup) { sb.AppendFormat("{0}: ", g.Key); foreach (var item in g) { sb.AppendFormat("{0},", item); } sb.AppendLine(); } return(sb.ToString()); }); zs = zs.Monitor("Lookup", 1, surrogate); #endregion zs = zs.Monitor("Lookup",...) zs.Wait(); }
public void WindowMinMaxTest() { var xs = Observable.Interval(TimeSpan.FromSeconds(1)).Take(12); xs = xs.Monitor("Interval", 1); var zs = from win in xs.Window(4).MonitorMany("Win", 2) let min = win.Min().Monitor("Min", 3) .Catch(Observable.Return(-1L)) let max = win.Max().Monitor("Max", 4).Catch(Observable.Return(-1L)) select Observable.Zip(min, max); var surrogate = new MonitorSurrogate <IList <long> >( (items, marbles) => string.Format("Min = {0}, Max = {1}", items[0], items[1])); var fs = zs.Switch().Monitor("Zip", 5, surrogate); //zs.Subscribe(); fs.Wait(); }
private static void Main(string[] args) { TryToOpenViewer(); var bc = new BlockingCollection <string>(); Task <VisualRxInitResult> info = VisualRxSettings.Initialize( VisualRxWcfDiscoveryProxy.Create()//, //MonitorWcfQueuedProxy.Create(), //VisualRxTraceSourceProxy.Create() ); #region Loaded Proxies Log VisualRxInitResult infos = info.Result; Console.WriteLine(infos); #endregion Loaded Proxies Log var surrogate = new MonitorSurrogate <IList <double> >(MarbleSerializationOptions.Serializable); var xs = StockProvider() .Buffer(2, 1) .Monitor("Stock", 100, surrogate); for (int i = 0; i < 4; i++) { int local = i; var ys = StockProvider(_rnd.Value.Next(50, 150)) .Buffer(2, 1) .Monitor("StockGraph " + local, local, surrogate); xs = xs.Merge(ys); } xs.Subscribe(_ => bc.Add(".")); foreach (var item in bc.GetConsumingEnumerable()) { Console.Write(item); } GC.KeepAlive(xs); }
/// <summary> /// Monitor Group by stream /// </summary> /// <typeparam name="TKey">The type of the key.</typeparam> /// <typeparam name="TElement">The type of the element.</typeparam> /// <param name="instance">The instance.</param> /// <param name="name">The name.</param> /// <param name="orderingBaseIndex">Index of the ordering base.</param> /// <param name="elementSurrogate">The element surrogate.</param> /// <param name="keywords">The keywords.</param> /// <returns></returns> public static IObservable <IGroupedObservable <TKey, TElement> > MonitorGroup <TKey, TElement>( this IObservable <IGroupedObservable <TKey, TElement> > instance, string name, double orderingBaseIndex, IMonitorSurrogate <TElement> elementSurrogate, params string[] keywords) { var keySurrogate = new MonitorSurrogate <IGroupedObservable <TKey, TElement> >( (g, m) => "Key = " + g.Key); instance = instance.Monitor(name + " (keys)", orderingBaseIndex, keySurrogate, keywords); int index = 0; var xs = from g in instance let idx = Interlocked.Increment(ref index) let ord = orderingBaseIndex + (idx / 100000.0) select new GroupedMonitored <TKey, TElement>( g, $"{name}:{g.Key} ({idx})", ord, elementSurrogate, keywords); return(xs); }
public void SimpleBufferTest() { var xs = Observable.Interval(TimeSpan.FromSeconds(0.5)) .Take(12); #region Monitor xs = xs.Monitor("Source", 1); #endregion Monitor var ws = xs.Buffer(4); #region Monitor var surrogate = new MonitorSurrogate <IList <long> > ( (buffer, marble) => string.Join(",", buffer)); ws = ws.Monitor("Buffered", 2, surrogate); #endregion Monitor ws.Wait(); }