Skip to content

Commit

Permalink
Add performance test for writing
Browse files Browse the repository at this point in the history
  • Loading branch information
jojoelfe committed Dec 2, 2023
1 parent 30bebdc commit ce192b1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/test_writing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from os.path import join as join_path
from tempfile import TemporaryDirectory
import time
import math

import pandas as pd
Expand All @@ -9,7 +10,7 @@
from starfile.writer import StarWriter

from .constants import loop_simple, postprocess, test_data_directory, test_df

from .utils import generate_large_star_file, remove_large_star_file

def test_write_simple_block():
s = StarParser(postprocess)
Expand Down Expand Up @@ -97,6 +98,14 @@ def test_string_quoting_loop_datablock(quotechar, quote_always, num_quotes, tmp_
assert df.loc[0, "just_space"] == s.data_blocks[""].loc[0, "just_space"]
assert math.isnan(s.data_blocks[""].loc[0, "empty_string"])

def test_writing_speed():
start = time.time()
generate_large_star_file()
end = time.time()
remove_large_star_file()

# Check that execution takes less than a second
assert end - start < 1

@pytest.mark.parametrize("quotechar, quote_always, num_quotes",
[('"', False, 6),
Expand Down

0 comments on commit ce192b1

Please sign in to comment.