-
-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compute average response times for used upstream destinations.
Signed-off-by: DL6ER <[email protected]>
- Loading branch information
Showing
8 changed files
with
113 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,52 @@ | ||
/* Pi-hole: A black hole for Internet advertisements | ||
* (c) 2019 Pi-hole, LLC (https://pi-hole.net) | ||
* Network-wide ad blocking via your own hardware. | ||
* | ||
* FTL Engine | ||
* Math Implementation | ||
* | ||
* This file is copyright under the latest version of the EUPL. | ||
* Please see LICENSE file for your rights under this license. */ | ||
|
||
#include "math.h" | ||
|
||
// Recursive function that returns square root | ||
// of a number with precision upto 5 decimal places | ||
double Square(double n, double i, double j) | ||
{ | ||
double mid = (i + j) / 2; | ||
double mul = mid * mid; | ||
|
||
if ((mul - n)*(mul - n) < (SQRT_PRECISION * SQRT_PRECISION)) | ||
{ | ||
return mid; | ||
} | ||
else if (mul < n) | ||
{ | ||
return Square(n, mid, j); | ||
} | ||
else | ||
{ | ||
return Square(n, i, mid); | ||
} | ||
} | ||
|
||
// Function to find the square root of n | ||
double my_sqrt(double n) | ||
{ | ||
// While the square root is not found | ||
for(double i = 1.0; true; i++) | ||
{ | ||
if ((i - n)*(i - n) < (SQRT_PRECISION * SQRT_PRECISION)) | ||
{ | ||
// If n is a perfect square | ||
return i; | ||
} | ||
else if (i * i > n) | ||
{ | ||
// Square root will lie in the interval i-1 and i | ||
return Square(n, i - 1, i); | ||
} | ||
i++; | ||
} | ||
} |
This file contains 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,25 @@ | ||
/* Pi-hole: A black hole for Internet advertisements | ||
* (c) 2019 Pi-hole, LLC (https://pi-hole.net) | ||
* Network-wide ad blocking via your own hardware. | ||
* | ||
* FTL Engine | ||
* Math Prototypes | ||
* | ||
* This file is copyright under the latest version of the EUPL. | ||
* Please see LICENSE file for your rights under this license. */ | ||
|
||
#ifndef MATH_H | ||
#define MATH_H | ||
|
||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
|
||
#define SQRT_PRECISION 1e-5 | ||
|
||
// Recursive function that returns square root | ||
double Square(double n, double i, double j); | ||
|
||
// Function to find the square root of n | ||
double my_sqrt(double n); | ||
|
||
#endif //MATH_H |
This file contains 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
586fee1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit has been mentioned on Pi-hole Userspace. There might be relevant details there:
https://discourse.pi-hole.net/t/grafity-db-neu-erstellen/26258/12
586fee1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit has been mentioned on Pi-hole Userspace. There might be relevant details there:
https://discourse.pi-hole.net/t/grafity-db-neu-erstellen/26258/12