1. A method for transforming asynchronous code into more efficient, logically equivalent asynchronous code, comprising: converting asynchronous program code into a first syntax tree; generating a dependency graph from the first syntax tree with each node of the dependency graph corresponding to a code statement and having an assigned weight; performing weighted topological sorting of the dependency graph to generate a sorted dependency graph, said performing weighted topological sorting including modifying an order of asynchronous code statements in the dependency graph based at least on weights assigned to nodes of the dependency graph; and converting the sorted dependency graph to refactored asynchronous code that is logically equivalent to the asynchronous program code.