diff --git a/libs/langgraph/bench/__main__.py b/libs/langgraph/bench/__main__.py index 9b191f68d..12d04a6ab 100644 --- a/libs/langgraph/bench/__main__.py +++ b/libs/langgraph/bench/__main__.py @@ -205,11 +205,23 @@ benchmarks = ( }, ), ( - "sequential_graph_200_nodes", + "sequential_50", + create_sequential(20).compile(), + create_sequential(20).compile(), + {"messages": []}, # Empty list of messages + ), + ( + "sequential_200", create_sequential(200).compile(), create_sequential(200).compile(), {"messages": []}, # Empty list of messages ), + # ( + # "sequential_1000", + # create_sequential(1000).compile(), + # create_sequential(1000).compile(), + # {"messages": []}, # Empty list of messages + # ), ) diff --git a/libs/langgraph/bench/sequential.py b/libs/langgraph/bench/sequential.py index cceffd627..3ab92912f 100644 --- a/libs/langgraph/bench/sequential.py +++ b/libs/langgraph/bench/sequential.py @@ -1,13 +1,18 @@ """Create a sequential no-op graph consisting of a few hundred nodes.""" from langgraph.graph import MessagesState, StateGraph +from langgraph.utils.runnable import RunnableCallable def create_sequential(number_nodes) -> StateGraph: """Create a sequential no-op graph consisting of a few hundred nodes.""" builder = StateGraph(MessagesState) - async def noop(state: MessagesState) -> None: + def noop(state: MessagesState) -> None: + """No-op function.""" + pass + + async def anoop(state: MessagesState) -> None: """No-op function.""" pass @@ -15,7 +20,7 @@ def create_sequential(number_nodes) -> StateGraph: for i in range(number_nodes): name = f"node_{i}" - builder.add_node(name, noop) + builder.add_node(name, RunnableCallable(noop, anoop)) builder.add_edge(prev_node, name) prev_node = name @@ -29,7 +34,7 @@ if __name__ == "__main__": import uvloop - graph = create_sequential(200).compile() + graph = create_sequential(2000).compile() input = {"messages": []} # Empty list of messages config = {"recursion_limit": 20000000000}