MCPcopy Create free account
hub / github.com/adny-code/fastgrind / list_functions

Method list_functions

tools/fastgrind.py:793–842  ·  view source on GitHub ↗
(
        self,
        thread_ids: Sequence[int] | None = None,
        query: str = "",
        limit: int | None = 200,
        sort: str = "alpha",
        start_ms: int | None = None,
        end_ms: int | None = None,
    )

Source from the content-addressed store, hash-verified

791 ]
792
793 def list_functions(
794 self,
795 thread_ids: Sequence[int] | None = None,
796 query: str = "",
797 limit: int | None = 200,
798 sort: str = "alpha",
799 start_ms: int | None = None,
800 end_ms: int | None = None,
801 ) -> list[dict[str, Any]]:
802 if thread_ids:
803 available: set[int] = set()
804 for thread_id in thread_ids:
805 available.update(self.reader.thread_function_directory.get(thread_id, []))
806 else:
807 available = set(range(1, len(self.reader.function_names)))
808
809 query_lower = query.casefold().strip()
810 items = []
811 for function_id in sorted(available):
812 canonical = self.reader.function_names[function_id] or ""
813 display = self.reader.display_names[function_id] or canonical
814 if query_lower and query_lower not in canonical.casefold() and query_lower not in display.casefold():
815 continue
816 items.append(
817 {
818 "function_id": function_id,
819 "canonical_name": canonical,
820 "display_name": display,
821 }
822 )
823
824 if sort == "hot" and items:
825 scores = {
826 row["function_id"]: row["value"]
827 for row in self.top_functions(
828 start_ms=start_ms,
829 end_ms=end_ms,
830 thread_ids=thread_ids,
831 limit=max(limit or 200, len(items)),
832 metric="net",
833 scope="exclusive",
834 )
835 }
836 items.sort(key=lambda item: (-abs(scores.get(item["function_id"], 0.0)), item["display_name"].casefold()))
837 else:
838 items.sort(key=lambda item: (item["display_name"].casefold(), item["canonical_name"].casefold()))
839
840 if limit is not None:
841 return items[:limit]
842 return items
843
844 def query_series(
845 self,

Callers 2

_dispatchMethod · 0.80
_refresh_functionsMethod · 0.80

Calls 1

top_functionsMethod · 0.95

Tested by

no test coverage detected