Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
232 changed files
with
621 additions
and
1,974 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// MovingAverage.h | ||
// iTerm | ||
// | ||
// Created by George Nachman on 7/28/13. | ||
// | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface MovingAverage : NSObject { | ||
double _alpha; | ||
double _value; | ||
NSTimeInterval _time; | ||
} | ||
|
||
@property (nonatomic, assign) double alpha; // Initialized to 0.5. | ||
@property (nonatomic, assign) double value; | ||
|
||
- (void)startTimer; | ||
- (NSTimeInterval)timeSinceTimerStarted; | ||
- (void)addValue:(double)value; | ||
- (BOOL)haveStartedTimer; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// MovingAverage.m | ||
// iTerm | ||
// | ||
// Created by George Nachman on 7/28/13. | ||
// | ||
// | ||
|
||
#import "MovingAverage.h" | ||
|
||
@implementation MovingAverage | ||
|
||
@synthesize alpha = _alpha; | ||
@synthesize value = _value; | ||
|
||
- (id)init { | ||
self = [super init]; | ||
if (self) { | ||
_alpha = 0.5; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)startTimer { | ||
_time = [NSDate timeIntervalSinceReferenceDate]; | ||
} | ||
|
||
- (NSTimeInterval)timeSinceTimerStarted { | ||
return [NSDate timeIntervalSinceReferenceDate] - _time; | ||
} | ||
|
||
- (void)addValue:(double)value { | ||
_value = _alpha * _value + (1.0 - _alpha) * value; | ||
} | ||
|
||
- (BOOL)haveStartedTimer { | ||
return _time > 0; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.