최초 프로젝트 업로드 (Script Auto Commit)
This commit is contained in:
49
test_cache_reuse.py
Normal file
49
test_cache_reuse.py
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
캐시 재활용 기능 테스트 스크립트
|
||||
짧은 범위(예: 2023-01-01 ~ 2023-06-30)로 요청했을 때
|
||||
더 넓은 범위의 캐시 파일(예: 2018-01-01 ~ 2023-12-31)을 재활용하는지 확인
|
||||
"""
|
||||
|
||||
import time
|
||||
import config
|
||||
import data_manager
|
||||
import pandas as pd
|
||||
|
||||
# 테스트 대상 티커들 (상위 5개만)
|
||||
test_tickers = ['000080', '000100', '000120', '000150', '000155']
|
||||
|
||||
# 짧은 범위 요청 (캐시에서 재활용 가능)
|
||||
start_date = "2023-01-01"
|
||||
end_date = "2023-06-30"
|
||||
|
||||
print("=" * 60)
|
||||
print("캐시 재활용 성능 테스트")
|
||||
print("=" * 60)
|
||||
print(f"요청 범위: {start_date} ~ {end_date}")
|
||||
print(f"대상 티커: {test_tickers}")
|
||||
print()
|
||||
|
||||
# 기본 설정 로드
|
||||
analysis_start = (pd.to_datetime(start_date) - pd.DateOffset(years=config.DATA_HISTORY_YEARS)).strftime('%Y-%m-%d')
|
||||
print(f"분석용 시작일(추가): {analysis_start}")
|
||||
print()
|
||||
|
||||
start_time = time.time()
|
||||
|
||||
# 각 티커별로 데이터 로드
|
||||
for ticker in test_tickers:
|
||||
t0 = time.time()
|
||||
df = data_manager.get_stock_data(ticker, analysis_start, end_date)
|
||||
elapsed = time.time() - t0
|
||||
|
||||
if not df.empty:
|
||||
print(f"✓ {ticker}: {len(df)} 행, {elapsed:.3f}초 로드")
|
||||
else:
|
||||
print(f"✗ {ticker}: 데이터 없음")
|
||||
|
||||
total_time = time.time() - start_time
|
||||
print()
|
||||
print(f"총 로드 시간: {total_time:.3f}초")
|
||||
print("=" * 60)
|
||||
Reference in New Issue
Block a user