test_crf_for_year.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. from timeit import default_timer as timer
  2. from src.unfccc_ghg_data.unfccc_crf_reader.crf_raw_for_year_sparse_arrays import (
  3. crf_raw_for_year_original_version,
  4. crf_raw_for_year_pandas,
  5. crf_raw_for_year_sparse_arrays,
  6. )
  7. def test_crf_for_year_original_version(tmp_path):
  8. start = timer()
  9. n_countries = 3
  10. crf_raw_for_year_original_version(
  11. submission_year=2023,
  12. submission_type="CRF",
  13. n_countries=n_countries,
  14. output_folder=tmp_path,
  15. )
  16. end = timer()
  17. print(f"Processing time: {end - start} seconds for {n_countries} countries")
  18. # Processing time: 9.024652959080413 seconds for 3 countries
  19. # Processing time: 93.27503691602033 seconds for 10 countries
  20. def test_crf_for_year_sparse_arrays(tmp_path):
  21. start = timer()
  22. n_countries = 20 # 100 will find 26 countries
  23. crf_raw_for_year_sparse_arrays(
  24. submission_year=1,
  25. submission_type="CRT",
  26. n_countries=n_countries,
  27. output_folder=tmp_path,
  28. )
  29. end = timer()
  30. print(f"Processing time: {end - start} seconds for {n_countries} countries")
  31. # Processing time: 34.15730241697747 seconds for 3 countries
  32. def test_crf_for_year_pandas(tmp_path):
  33. start = timer()
  34. n_countries = 3
  35. crf_raw_for_year_pandas(
  36. submission_year=2023,
  37. type="CRF",
  38. n_countries=n_countries,
  39. output_folder=tmp_path,
  40. )
  41. end = timer()
  42. print(f"Processing time: {end - start} seconds for {n_countries} countries")