forked from UnitTestBot/klee
-
Notifications
You must be signed in to change notification settings - Fork 0
Added a module that tracks statistics and sends them to the server #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
YazoonDinalt
wants to merge
22
commits into
main
Choose a base branch
from
statistics
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
db55383
feat: Add simple metrics
YazoonDinalt c3bc233
feat: Add viewing statistics for individual functions
YazoonDinalt ecd344e
feat: Add a separate statistics function
YazoonDinalt f3fb9d3
feat: Add print statistics in delta time
YazoonDinalt 049ab98
feat: Change type Calculate Delta function
YazoonDinalt 11fb1fc
feat: Add output of statistics for each function by time delta
YazoonDinalt 2e7c104
fix: Fix bug with incorrect metrics calculation
YazoonDinalt 67dd22e
feat: Add save metrics on server
YazoonDinalt d7a9128
feat: Moving network interaction into a separate class
YazoonDinalt 58eb576
feat: Remove check all states
YazoonDinalt b3b1ec7
feat: Add data queue and remove useless function
YazoonDinalt 0d322b3
feat: Add desription in StatisticQueue
YazoonDinalt 70f42b4
feat: Remove useless function and fix bug with collect metrics
YazoonDinalt 43a7fdd
refactor: Remove useless include
YazoonDinalt 840c2db
feat: Add sending only non-zero metrics and removed unnecessary logging
YazoonDinalt 4cca3fb
feat: Fix wrong calculate in main
YazoonDinalt 318462e
feat: Add SolverTime in metrics
YazoonDinalt ed63878
feat: Fix main problem with data race and init curl on every function…
YazoonDinalt d385cb8
feat: Move some data to command line option
YazoonDinalt 81a64f5
feat: Change serialize and rename delta class
YazoonDinalt a138d62
fix: Add localStatisticMap to executor
YazoonDinalt b816beb
fix: Data race direct solution method
YazoonDinalt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| //===--MetricCollectorAndSerializer.cpp---------------------------*-C++ -*-===// | ||
| // | ||
| // The KLEE Symbolic Virtual Machine | ||
| // | ||
| // This file is distributed under the University of Illinois Open Source | ||
| // License. See LICENSE.TXT for details. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "MetricCollectorAndSerializer.h" | ||
| #include "CoreStats.h" | ||
|
|
||
| using namespace klee; | ||
|
|
||
| const double NANOSECONDS_PER_SECOND = 1000000000.0; | ||
|
|
||
| std::vector<nlohmann::json> MetricCollectorAndSerializer::GetJson( | ||
| const std::unordered_map<const llvm::Function *, | ||
| std::unordered_map<std::string, int>> &DelMap, | ||
| std::string UID) { | ||
|
|
||
| std::vector<nlohmann::json> jsonArray = SerializeDelMap(DelMap, UID); | ||
|
|
||
| previousMap = jsonArray; | ||
|
|
||
| return jsonArray; | ||
| } | ||
|
|
||
| std::vector<nlohmann::json> MetricCollectorAndSerializer::SerializeDelMap( | ||
| const std::unordered_map<const llvm::Function *, | ||
| std::unordered_map<std::string, int>> &DelMap, | ||
| const std::string UID) { | ||
|
|
||
| std::vector<nlohmann::json> jsonArray; | ||
|
|
||
| for (const auto &funPair : DelMap) { | ||
| auto funName = funPair.first->getName(); | ||
| const auto &metricsMap = funPair.second; | ||
|
|
||
| for (const auto &metricPair : metricsMap) { | ||
| const std::string &metricName = metricPair.first; | ||
| uint64_t prev; | ||
| auto count = metricPair.second; | ||
| for (const auto &jsonObject : previousMap) { | ||
| if (jsonObject["params"]["funName"] == funName && | ||
| jsonObject["name"] == metricName) { | ||
| prev = jsonObject["params"]["value"]; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| if (count - prev != 0) { | ||
| if (metricName == "SolverTime") { | ||
| double solverCount = | ||
| static_cast<double>(count) / NANOSECONDS_PER_SECOND; | ||
| solverCount = static_cast<double>(round(solverCount * 100)) / 100; | ||
| jsonArray.push_back({{"guid", UID}, | ||
| {"name", metricName}, | ||
| {"params", | ||
| {{"funName", funName}, | ||
| {"type", "double"}, | ||
| {"value", solverCount}, | ||
| {"transitive", false}}}}); | ||
| } else { | ||
| jsonArray.push_back({{"guid", UID}, | ||
| {"name", metricName}, | ||
| {"params", | ||
| {{"funName", funName}, | ||
| {"type", "int"}, | ||
| {"value", count}, | ||
| {"transitive", false}}}}); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return jsonArray; | ||
| } | ||
|
|
||
| std::unordered_map<const llvm::Function *, std::unordered_map<std::string, int>> | ||
| MetricCollectorAndSerializer::getCurrentMetric( | ||
| std::unordered_map<CallPathNode *, StatisticRecord *> StatMap) { | ||
|
|
||
| std::unordered_map<const llvm::Function *, | ||
| std::unordered_map<std::string, int>> | ||
| DelMap; | ||
|
|
||
| std::lock_guard<std::mutex> lock(StatisticMapMutex); | ||
| for (const auto &pair : StatMap) { | ||
| CallPathNode *cpn = pair.first; | ||
| DelMap[cpn->function]["Instructions"] += | ||
| pair.second->getValue(stats::instructions); | ||
| DelMap[cpn->function]["SolverTime"] += | ||
| pair.second->getValue(stats::solverTime); | ||
| DelMap[cpn->function]["Forks"] += pair.second->getValue(stats::forks); | ||
| } | ||
|
|
||
| return DelMap; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| //===--MetricCollectorAndSerializer.h-----------------------------*-C++ -*-===// | ||
| // | ||
| // The KLEE Symbolic Virtual Machine | ||
| // | ||
| // This file is distributed under the University of Illinois Open Source | ||
| // License. See LICENSE.TXT for details. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef KLEE_GETDELTA_H | ||
| #define KLEE_GETDELTA_H | ||
|
|
||
| #include "CallPathManager.h" | ||
| #include "nlohmann/json.hpp" | ||
| #include "llvm/IR/Function.h" | ||
|
|
||
| #include <mutex> | ||
|
|
||
| namespace klee { | ||
|
|
||
| class MetricCollectorAndSerializer { | ||
| private: | ||
| std::vector<nlohmann::json> previousMap; | ||
| std::mutex StatisticMapMutex; | ||
| std::unordered_map<const llvm::Function *, std::map<std::string, int>> Delta; | ||
|
|
||
| std::vector<nlohmann::json> SerializeDelMap( | ||
| const std::unordered_map<const llvm::Function *, | ||
| std::unordered_map<std::string, int>> &DelMap, | ||
| const std::string UID); | ||
|
|
||
| public: | ||
| std::vector<nlohmann::json> GetJson( | ||
| const std::unordered_map<const llvm::Function *, | ||
| std::unordered_map<std::string, int>> &DelMap, | ||
| const std::string UID); | ||
|
|
||
| std::unordered_map<const llvm::Function *, | ||
| std::unordered_map<std::string, int>> | ||
| getCurrentMetric(std::unordered_map<CallPathNode *, StatisticRecord *>); | ||
| }; | ||
| } // namespace klee | ||
|
|
||
| #endif /* KLEE_DELTA_H */ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.