From: Michael Tremer Date: Tue, 21 Feb 2023 17:03:04 +0000 (+0000) Subject: python: Drop performance_index function X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7323896e0b3ac22d4425aa54df61a43e9c74d659;p=people%2Fstevee%2Fpakfire.git python: Drop performance_index function We no longer use this. Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/_pakfiremodule.c b/src/_pakfire/_pakfiremodule.c index 839d0ac7..26bb5a63 100644 --- a/src/_pakfire/_pakfiremodule.c +++ b/src/_pakfire/_pakfiremodule.c @@ -91,7 +91,6 @@ ERROR: } static PyMethodDef pakfireModuleMethods[] = { - {"performance_index", (PyCFunction)performance_index, METH_VARARGS, NULL}, {"native_arch", (PyCFunction)_pakfire_native_arch, METH_NOARGS, NULL }, {"supported_arches", (PyCFunction)_pakfire_supported_arches, METH_NOARGS, NULL }, { NULL, NULL, 0, NULL } diff --git a/src/_pakfire/util.c b/src/_pakfire/util.c index 4f883d09..a5d282fa 100644 --- a/src/_pakfire/util.c +++ b/src/_pakfire/util.c @@ -22,8 +22,6 @@ #include #include -#include -#include #include #include @@ -33,58 +31,6 @@ #include "package.h" #include "util.h" -static unsigned long fibonnacci(const clock_t* deadline) { - clock_t now = clock(); - - unsigned long f1 = 1; - unsigned long f2 = 1; - - // Count iterations - unsigned long counter = 0; - - while (now < *deadline) { - unsigned long next = f1 + f2; - f1 = f2; - f2 = next; - - now = clock(); - counter++; - } - - return counter; -} - -PyObject* performance_index(PyObject* self, PyObject* args) { - int seconds = 1; - - if (!PyArg_ParseTuple(args, "|i", &seconds)) { - return NULL; - } - - if (seconds == 0) { - PyErr_SetString(PyExc_ValueError, "Runtime must be one second or longer"); - return NULL; - } - - // Determine the number of online processors - int processors = sysconf(_SC_NPROCESSORS_ONLN); - - // Determine deadline - clock_t deadline = clock(); - deadline += CLOCKS_PER_SEC * seconds; - - // Run Fibonnacci until deadline - unsigned long iterations = fibonnacci(&deadline); - - // Times the result by the number of processors - iterations *= processors; - - // Normalise to a second - iterations /= seconds; - - return PyLong_FromUnsignedLong(iterations); -} - PyObject* PyList_FromPackageList(struct pakfire_packagelist* packagelist) { PyObject* list = PyList_New(0); diff --git a/src/_pakfire/util.h b/src/_pakfire/util.h index e9cf9fe7..c014a08e 100644 --- a/src/_pakfire/util.h +++ b/src/_pakfire/util.h @@ -26,8 +26,6 @@ #include #include -extern PyObject* performance_index(PyObject* self, PyObject* args); - PyObject* PyList_FromPackageList(struct pakfire_packagelist* packagelist); PyObject* PyList_FromFileList(struct pakfire_filelist* filelist);