Skip to content

using a setup function in benchmarks #125

@akshitasure12

Description

@akshitasure12

I expect that we will need many different types of graphs for the algorithms. So the get_graph May not be able to be used very often. At least that is what happens with tests and pytest. We create a test class and put some graphs that could be used by lots of tests, but then they end up only being used by a couple of the tests and the rest construct their own graph. So we may want to create a different setup function for many of the timing functions. I think we’ll have to wait to see what is most useful. Keeping it as a common function is fine with me. Could we name it something like: cached_gnp_random_graph?

Originally posted by @dschult in #24 (comment)

I was working through the benchmarks and realized that for the tournament functions, we’re currently including the graph generation time in the benchmark measurements, possibly skewing the results.

def time_is_reachable(self, backend, num_nodes):
        G = nx.tournament.random_tournament(num_nodes, seed=42)
        _ = nx.tournament.is_reachable(G, 0, num_nodes - 1, backend=backend)

Following the way benchmarks are implemented in NetworkX, I was thinking of introducing a setup function in nx-parallel, at least for the tournament benchmark, which seems to need a different graph structure. That said, I was also wondering if we should aim for a more uniform setup approach across all benchmarks.

[Note]: I read through PR#24, and it looks like most benchmarks work well with the current cached graph approach. If we decide to continue using the cached graph, perhaps we could introduce a dedicated setup function only for the tournament benchmark. Please let me know your thoughts on this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions