-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_usage.py
More file actions
71 lines (50 loc) · 2.01 KB
/
Copy pathexample_usage.py
File metadata and controls
71 lines (50 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python3
"""
Example usage of the SpeedAnalyzer class.
This demonstrates various ways to use the speed analyzer.
"""
from speed_analyzer import SpeedAnalyzer
SPEED_TESTING_DIR = "test_speed_data"
def example_single_file():
"""Example: Analyze a single file."""
print("=== EXAMPLE 1: Single File Analysis ===")
analyzer = SpeedAnalyzer()
results = analyzer.analyze_single_file(f"{SPEED_TESTING_DIR}/test_speed_1.csv")
analyzer.display_results(results)
def example_multiple_specific_files():
"""Example: Analyze specific multiple files."""
print("\n=== EXAMPLE 2: Multiple Specific Files ===")
analyzer = SpeedAnalyzer()
# List of specific files to analyze
files_to_analyze = [
f"{SPEED_TESTING_DIR}/test_speed_1.csv",
f"{SPEED_TESTING_DIR}/test_speed_2.csv",
f"{SPEED_TESTING_DIR}/test_speed_3.csv"
]
analyzer.analyze_multiple_files(files_to_analyze)
def example_custom_analysis():
"""Example: Custom analysis with additional processing."""
print("\n=== EXAMPLE 3: Custom Analysis ===")
analyzer = SpeedAnalyzer()
# Analyze mycomputer.csv and get raw data
results = analyzer.analyze_single_file(f"{SPEED_TESTING_DIR}/test_speed_1.csv")
if results:
speeds = results['speeds_mbps']
# Custom calculations
min_speed = min(speeds)
max_speed = max(speeds)
speed_range = max_speed - min_speed
print(f"\n--- Custom Analysis for {results['filename']} ---")
print(f"Minimum speed: {min_speed:.2f} Mbps")
print(f"Maximum speed: {max_speed:.2f} Mbps")
print(f"Speed range: {speed_range:.2f} Mbps")
print(f"Speed variation: {(speed_range/results['average_mbps'])*100:.1f}%")
def main():
"""Run all examples."""
example_single_file()
example_multiple_specific_files()
example_custom_analysis()
print("\n" + "="*60)
print("All examples completed!")
if __name__ == "__main__":
main()