public FpsCounterViewModel() { MouseDownUnit = new ReactivePropertySlim <Unit>(mode: ReactivePropertyMode.None).AddTo(CompositeDisposable); // http://reactivex.io/documentation/operators/buffer.html // Buffer(count, skip) : count個のデータが溜まったら、skip個ごとに count個をまとめた List<T> を流します // Buffer(count) : countの倍数で、count個をまとめた List<T> を流します。 FpsCounter1 = MouseDownUnit .Select(_ => DateTime.Now) .Pairwise() .Select(dateTime => dateTime.NewItem - dateTime.OldItem) .Buffer(count: _bufferLength, skip: 1) .Select(tss => 1000d / tss.Select(ts => ts.TotalMilliseconds).Average()) .ToReadOnlyReactivePropertySlim() .AddTo(CompositeDisposable); FpsCounter2 = MouseDownUnit .TimeInterval() .Buffer(count: _bufferLength, skip: 1) .Select(xs => 1000d / xs.Select(x => x.Interval.Milliseconds).Average()) .ToReadOnlyReactivePropertySlim() .AddTo(CompositeDisposable); FpsCounter3 = MouseDownUnit .Framerate(_bufferLength) .ToReadOnlyReactivePropertySlim() .AddTo(CompositeDisposable); }