Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b7bdc05a2 | |||
| 7cd7f33955 | |||
| 8e63bf1c18 | |||
| 8cce27c295 | |||
| 11303d3e2b | |||
| 9d2aabbd32 |
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h> // pour f2
|
||||
|
||||
#define NB_TRANSACTIONS 30000
|
||||
#define NB_CLIENTS 2000
|
||||
@@ -71,38 +72,142 @@ Transaction *generer_transactions(int n)
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
/* F1 : trie les transactions par montant croissant, puis par id */
|
||||
void trier_par_montant(Transaction *t, int n)
|
||||
{
|
||||
for (int i = 0; i < n - 1; i++) {
|
||||
for (int j = 0; j < n - 1 - i; j++) {
|
||||
if (t[j].montant > t[j + 1].montant ||
|
||||
(t[j].montant == t[j + 1].montant && t[j].id > t[j + 1].id)) {
|
||||
Transaction tmp = t[j];
|
||||
t[j] = t[j + 1];
|
||||
t[j + 1] = tmp;
|
||||
static void fusionner(Transaction *t, int debut, int milieu, int fin) {
|
||||
int n1 = milieu - debut + 1;
|
||||
int n2 = fin - milieu;
|
||||
|
||||
Transaction *gauche = malloc(n1 * sizeof(Transaction));
|
||||
Transaction *droite = malloc(n2 * sizeof(Transaction));
|
||||
|
||||
for (int i = 0; i < n1; i++)
|
||||
gauche[i] = t[debut + i];
|
||||
for (int j = 0; j < n2; j++)
|
||||
droite[j] = t[milieu + 1 + j];
|
||||
|
||||
int i = 0, j = 0, k = debut;
|
||||
|
||||
while (i < n1 && j < n2) {
|
||||
if (gauche[i].montant < droite[j].montant ||
|
||||
(gauche[i].montant == droite[j].montant && gauche[i].id <= droite[j].id)) {
|
||||
t[k++] = gauche[i++];
|
||||
} else {
|
||||
t[k++] = droite[j++];
|
||||
}
|
||||
}
|
||||
|
||||
while (i < n1)
|
||||
t[k++] = gauche[i++];
|
||||
while (j < n2)
|
||||
t[k++] = droite[j++];
|
||||
|
||||
free(gauche);
|
||||
free(droite);
|
||||
}
|
||||
|
||||
void trier_par_montant(Transaction *t, int n) {
|
||||
if (n <= 1) return;
|
||||
|
||||
for (int taille = 1; taille < n; taille *= 2) {
|
||||
for (int debut = 0; debut < n - 1; debut += 2 * taille) {
|
||||
int milieu = debut + taille - 1;
|
||||
int fin = (debut + 2 * taille - 1 < n - 1) ? (debut + 2 * taille - 1) : (n - 1);
|
||||
|
||||
if (milieu < fin) {
|
||||
fusionner(t, debut, milieu, fin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* F2 : nombre de clients ayant au moins une transaction */
|
||||
int nb_clients_distincts(const Transaction *t, int n)
|
||||
|
||||
|
||||
|
||||
|
||||
int nb_clients_distincts(const Transaction *t, int n) // on utilise l'id come index
|
||||
{
|
||||
int nb = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
int deja_vu = 0;
|
||||
for (int j = 0; j < i; j++) {
|
||||
if (t[j].client == t[i].client) {
|
||||
deja_vu = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (n <= 0) return 0;
|
||||
|
||||
|
||||
|
||||
|
||||
// on trouve l'id/index max pr la taille du tableau
|
||||
|
||||
int max_id = t[0].client;
|
||||
|
||||
|
||||
for (int i = 1; i < n; i++)
|
||||
{
|
||||
|
||||
if (t[i].client > max_id)
|
||||
{
|
||||
|
||||
max_id = t[i].client;
|
||||
|
||||
}
|
||||
if (!deja_vu)
|
||||
nb++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// creation du tableau
|
||||
|
||||
bool *presence = (bool *)calloc(max_id + 1, sizeof(bool));
|
||||
|
||||
|
||||
if (presence == NULL) // si le tableau est vide (ne devrait pas arriver sauf si j'ai mal fais les choses)
|
||||
{
|
||||
|
||||
return -1; // on sort direct de la fonction
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// on compte les clients
|
||||
|
||||
int nb = 0;
|
||||
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
|
||||
int id_client = t[i].client;
|
||||
|
||||
if (!presence[id_client]) // si client pas vu
|
||||
{
|
||||
|
||||
presence[id_client] = true; // marquer comme vu
|
||||
nb++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
free(presence); // j'ai du mal avc la memoire dcp honnetement c gemini qui m'a dit de faire ca (cleo)
|
||||
|
||||
return nb;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* F3 : solde total de chaque client */
|
||||
void total_par_client(const Transaction *t, int n, long *totaux)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
# Compte rendu — TD3 Complexité algorithmique (R5.A.04)
|
||||
|
||||
## 1. Complexités algorithmiques
|
||||
|
||||
| Fonction | Rôle | Avant | Après |
|
||||
|---|---|---|---|
|
||||
| F1 | `trier_par_montant` — tri par montant puis par id | O(n²) | **O(n log n)** (tri fusion) |
|
||||
| F2 | `nb_clients_distincts` | O(n²) | **O(n + c)** (tableau de présence) |
|
||||
| F3 | `total_par_client` | O(n·c) | |
|
||||
| F4 | `total_par_jour` | O(n·J) | |
|
||||
| F5 | `meilleure_periode` | O(J³) | |
|
||||
| F6 | `rechercher_par_id` | O(n) | |
|
||||
| F7 | `nb_paires_opposees` | O(n²) | |
|
||||
| F8 | `nb_facons_rendre` | O(2^S) | |
|
||||
| F9 | `categorie` | M = 14 | |
|
||||
| F10 | `ajouter_ligne` | O(L) | |
|
||||
|
||||
## 2. Profil gprof initial
|
||||
|
||||
Programme d'origine compilé avec `gcc -O0 -g -pg`, temps total mesuré : **6,83 s**.
|
||||
|
||||

|
||||
|
||||
`trier_par_montant` représente à elle seule **48 %** du temps (3,28 s) : c'est la première fonction à optimiser.
|
||||
|
||||
## 3. Optimisations
|
||||
|
||||
### 3.1 F1 — `trier_par_montant` : tri à bulles → tri fusion
|
||||
|
||||
**Avant :** tri à bulles, deux boucles imbriquées qui comparent et échangent les éléments voisins → O(n²).
|
||||
|
||||
**Après :** tri fusion itératif (ascendant). On fusionne des sous-tableaux triés de taille 1, 2, 4, 8… jusqu'à couvrir tout le tableau. La fonction `fusionner` copie les deux moitiés dans des tableaux temporaires puis les recombine dans l'ordre → O(n log n).
|
||||
|
||||
L'ordre de tri est conservé (montant croissant, puis id croissant en cas d'égalité), donc l'empreinte reste `ff68d260a7a58441`.
|
||||
|
||||
**Profil gprof après modification :**
|
||||
|
||||

|
||||
|
||||
| | Avant | Après |
|
||||
|---|---|---|
|
||||
| Temps de `trier_par_montant` | 3,28 s | 0,01 s (via `fusionner`) |
|
||||
| Temps total du programme | 6,83 s | 3,06 s |
|
||||
|
||||
Le tri passe de 48 % du temps à un coût négligeable ; le temps total est divisé par plus de 2. Les fonctions les plus coûteuses sont maintenant `nb_facons_rendre` (30 %), `nb_paires_opposees` (24 %) et `rechercher_par_id` (22 %).
|
||||
|
||||
### 3.2 F2 — `nb_clients_distincts` : double boucle → tableau de présence
|
||||
|
||||
**Avant :** pour chaque transaction, on reparcourt toutes les transactions précédentes pour savoir si le client a déjà été vu → O(n²).
|
||||
|
||||
**Après :** l'id du client sert directement d'index dans un tableau de booléens `presence` :
|
||||
1. un premier parcours trouve l'id client maximal pour dimensionner le tableau ;
|
||||
2. le tableau est alloué avec `calloc` (initialisé à `false`) ;
|
||||
3. un second parcours marque chaque client rencontré et incrémente le compteur la première fois qu'il est vu ;
|
||||
4. le tableau est libéré avec `free`.
|
||||
|
||||
Chaque vérification « déjà vu ? » se fait en O(1), d'où une complexité O(n + c) (c = nombre de clients). Le résultat est identique, l'empreinte est inchangée.
|
||||
|
||||
**Profil gprof après modification :**
|
||||
|
||||

|
||||
|
||||
| | Avant | Après |
|
||||
|---|---|---|
|
||||
| Temps de `nb_clients_distincts` | 0,11 s | 0,00 s |
|
||||
| Temps total du programme | 3,06 s | 3,07 s |
|
||||
|
||||
La fonction devient négligeable dans le profil. Le gain sur le temps total n'est pas visible car il est inférieur aux variations de mesure de gprof (échantillonnage à 0,01 s). Les fonctions les plus coûteuses restent `nb_facons_rendre` (28 %), `nb_paires_opposees` (26 %) et `rechercher_par_id` (25 %).
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 60 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
+332
@@ -0,0 +1,332 @@
|
||||
/*
|
||||
* R5.A.04 - Qualité Algorithmique
|
||||
* TD Complexité algorithmique : analyse des transactions d'une banque
|
||||
*
|
||||
* Le programme génère des transactions pseudo-aléatoires (toujours les
|
||||
* mêmes, grâce à une graine fixe), puis calcule plusieurs indicateurs
|
||||
* et produit un rapport dans rapport.txt.
|
||||
*
|
||||
* L'empreinte affichée à la fin doit rester IDENTIQUE après vos
|
||||
* optimisations : elle prouve que le résultat n'a pas changé.
|
||||
*
|
||||
* Interdit : modifier les constantes, la génération des données,
|
||||
* le format du rapport, ou écrire les résultats « en dur ».
|
||||
*
|
||||
* Compilation : gcc -O2 banque.c -o banque
|
||||
* Profiling : gcc -O0 -g -pg banque.c -o banque && ./banque && gprof ./banque gmon.out
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define NB_TRANSACTIONS 30000
|
||||
#define NB_CLIENTS 2000
|
||||
#define NB_JOURS 1000
|
||||
#define NB_REQUETES 30000
|
||||
#define MONTANT_MONNAIE 400
|
||||
#define GRAINE 20261020UL
|
||||
|
||||
typedef struct {
|
||||
int id;
|
||||
int client;
|
||||
int jour;
|
||||
long montant; /* en centimes, négatif pour un débit */
|
||||
} Transaction;
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Données (ne pas modifier) */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
static unsigned long etat_alea = GRAINE;
|
||||
|
||||
unsigned long alea(void)
|
||||
{
|
||||
etat_alea = etat_alea * 6364136223846793005UL + 1442695040888963407UL;
|
||||
return etat_alea >> 33;
|
||||
}
|
||||
|
||||
Transaction *generer_transactions(int n)
|
||||
{
|
||||
Transaction *t = malloc(n * sizeof(Transaction));
|
||||
for (int i = 0; i < n; i++) {
|
||||
t[i].id = i;
|
||||
t[i].client = alea() % NB_CLIENTS;
|
||||
t[i].jour = alea() % NB_JOURS;
|
||||
if (i > 0 && alea() % 20 == 0)
|
||||
t[i].montant = -t[alea() % i].montant; /* opération inverse */
|
||||
else
|
||||
t[i].montant = (long)(alea() % 100001) - 50000;
|
||||
}
|
||||
for (int i = n - 1; i > 0; i--) { /* mélange des id */
|
||||
int j = alea() % (i + 1);
|
||||
int tmp = t[i].id;
|
||||
t[i].id = t[j].id;
|
||||
t[j].id = tmp;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Fonctions à analyser et à optimiser */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
/* F1 : trie les transactions par montant croissant, puis par id */
|
||||
void trier_par_montant(Transaction *t, int n)
|
||||
{
|
||||
for (int i = 0; i < n - 1; i++) {
|
||||
for (int j = 0; j < n - 1 - i; j++) {
|
||||
if (t[j].montant > t[j + 1].montant ||
|
||||
(t[j].montant == t[j + 1].montant && t[j].id > t[j + 1].id)) {
|
||||
Transaction tmp = t[j];
|
||||
t[j] = t[j + 1];
|
||||
t[j + 1] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* F2 : nombre de clients ayant au moins une transaction */
|
||||
int nb_clients_distincts(const Transaction *t, int n)
|
||||
{
|
||||
int nb = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
int deja_vu = 0;
|
||||
for (int j = 0; j < i; j++) {
|
||||
if (t[j].client == t[i].client) {
|
||||
deja_vu = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!deja_vu)
|
||||
nb++;
|
||||
}
|
||||
return nb;
|
||||
}
|
||||
|
||||
/* F3 : solde total de chaque client */
|
||||
void total_par_client(const Transaction *t, int n, long *totaux)
|
||||
{
|
||||
for (int c = 0; c < NB_CLIENTS; c++) {
|
||||
totaux[c] = 0;
|
||||
for (int i = 0; i < n; i++)
|
||||
if (t[i].client == c)
|
||||
totaux[c] += t[i].montant;
|
||||
}
|
||||
}
|
||||
|
||||
/* F4 : solde total de chaque jour */
|
||||
void total_par_jour(const Transaction *t, int n, long *totaux)
|
||||
{
|
||||
for (int j = 0; j < NB_JOURS; j++) {
|
||||
totaux[j] = 0;
|
||||
for (int i = 0; i < n; i++)
|
||||
if (t[i].jour == j)
|
||||
totaux[j] += t[i].montant;
|
||||
}
|
||||
}
|
||||
|
||||
/* F5 : période de jours consécutifs dont la somme des soldes est maximale */
|
||||
long meilleure_periode(const long *totaux, int nb_jours, int *debut, int *fin)
|
||||
{
|
||||
long meilleur = totaux[0];
|
||||
*debut = 0;
|
||||
*fin = 0;
|
||||
for (int i = 0; i < nb_jours; i++) {
|
||||
for (int j = i; j < nb_jours; j++) {
|
||||
long somme = 0;
|
||||
for (int k = i; k <= j; k++)
|
||||
somme += totaux[k];
|
||||
if (somme > meilleur) {
|
||||
meilleur = somme;
|
||||
*debut = i;
|
||||
*fin = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
return meilleur;
|
||||
}
|
||||
|
||||
/* F6 : retrouve une transaction à partir de son id */
|
||||
const Transaction *rechercher_par_id(const Transaction *t, int n, int id)
|
||||
{
|
||||
for (int i = 0; i < n; i++)
|
||||
if (t[i].id == id)
|
||||
return &t[i];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* F7 : nombre de paires de transactions de montants opposés (a + b = 0) */
|
||||
long nb_paires_opposees(const Transaction *t, int n)
|
||||
{
|
||||
long nb = 0;
|
||||
for (int i = 0; i < n; i++)
|
||||
for (int j = i + 1; j < n; j++)
|
||||
if (t[i].montant + t[j].montant == 0)
|
||||
nb++;
|
||||
return nb;
|
||||
}
|
||||
|
||||
/* F8 : nombre de façons de rendre une somme avec les pièces disponibles */
|
||||
static const int PIECES[] = {1, 2, 5, 10, 20, 50, 100, 200};
|
||||
#define NB_PIECES 8
|
||||
|
||||
long nb_facons_rendre(int somme, int nb_pieces)
|
||||
{
|
||||
if (somme == 0)
|
||||
return 1;
|
||||
if (somme < 0 || nb_pieces == 0)
|
||||
return 0;
|
||||
return nb_facons_rendre(somme - PIECES[nb_pieces - 1], nb_pieces) +
|
||||
nb_facons_rendre(somme, nb_pieces - 1);
|
||||
}
|
||||
|
||||
/* F9 : catégorie d'une transaction (pour les statistiques) */
|
||||
int categorie(const Transaction *t)
|
||||
{
|
||||
if (t->montant < 0) {
|
||||
if (t->montant < -20000) {
|
||||
if (t->jour % 7 == 5 || t->jour % 7 == 6)
|
||||
return 1;
|
||||
else
|
||||
return 2;
|
||||
} else if (t->montant < -5000) {
|
||||
return 3;
|
||||
} else {
|
||||
if (t->client % 10 == 0)
|
||||
return 4;
|
||||
return 5;
|
||||
}
|
||||
} else if (t->montant == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
if (t->montant > 30000) {
|
||||
if (t->client % 10 == 0 && t->jour % 7 < 5)
|
||||
return 6;
|
||||
return 7;
|
||||
} else if (t->montant > 10000) {
|
||||
return 8;
|
||||
} else if (t->montant > 1000) {
|
||||
if (t->jour % 30 == 0)
|
||||
return 9;
|
||||
return 10;
|
||||
}
|
||||
return 11;
|
||||
}
|
||||
}
|
||||
|
||||
/* F10 : ajoute une ligne à la fin du rapport */
|
||||
int longueur(const char *s)
|
||||
{
|
||||
int n = 0;
|
||||
while (s[n] != '\0')
|
||||
n++;
|
||||
return n;
|
||||
}
|
||||
|
||||
void ajouter_ligne(char *rapport, const char *ligne)
|
||||
{
|
||||
int fin = longueur(rapport);
|
||||
int i = 0;
|
||||
while (ligne[i] != '\0') {
|
||||
rapport[fin + i] = ligne[i];
|
||||
i++;
|
||||
}
|
||||
rapport[fin + i] = '\0';
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Programme principal (à adapter si vous changez les signatures) */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
unsigned long empreinte(const char *s)
|
||||
{
|
||||
unsigned long h = 1469598103934665603UL;
|
||||
for (int i = 0; s[i] != '\0'; i++) {
|
||||
h ^= (unsigned char)s[i];
|
||||
h *= 1099511628211UL;
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Transaction *t = generer_transactions(NB_TRANSACTIONS);
|
||||
char *rapport = malloc(1 << 20);
|
||||
char ligne[128];
|
||||
rapport[0] = '\0';
|
||||
|
||||
/* recherches par id, dans l'ordre d'origine */
|
||||
long somme_requetes = 0;
|
||||
unsigned long etat = 12345;
|
||||
for (int q = 0; q < NB_REQUETES; q++) {
|
||||
etat = etat * 1103515245UL + 12345UL;
|
||||
const Transaction *r = rechercher_par_id(t, NB_TRANSACTIONS, (int)((etat >> 8) % NB_TRANSACTIONS));
|
||||
if (r != NULL)
|
||||
somme_requetes += r->montant;
|
||||
}
|
||||
|
||||
int nb_clients = nb_clients_distincts(t, NB_TRANSACTIONS);
|
||||
|
||||
static long totaux_clients[NB_CLIENTS];
|
||||
total_par_client(t, NB_TRANSACTIONS, totaux_clients);
|
||||
|
||||
static long totaux_jours[NB_JOURS];
|
||||
total_par_jour(t, NB_TRANSACTIONS, totaux_jours);
|
||||
int debut, fin;
|
||||
long meilleure = meilleure_periode(totaux_jours, NB_JOURS, &debut, &fin);
|
||||
|
||||
long nb_paires = nb_paires_opposees(t, NB_TRANSACTIONS);
|
||||
|
||||
int categories[12] = {0};
|
||||
for (int i = 0; i < NB_TRANSACTIONS; i++)
|
||||
categories[categorie(&t[i])]++;
|
||||
|
||||
trier_par_montant(t, NB_TRANSACTIONS);
|
||||
|
||||
long nb_facons = nb_facons_rendre(MONTANT_MONNAIE, NB_PIECES);
|
||||
|
||||
/* rapport */
|
||||
snprintf(ligne, sizeof(ligne), "clients distincts;%d\n", nb_clients);
|
||||
ajouter_ligne(rapport, ligne);
|
||||
snprintf(ligne, sizeof(ligne), "somme des requetes;%ld\n", somme_requetes);
|
||||
ajouter_ligne(rapport, ligne);
|
||||
snprintf(ligne, sizeof(ligne), "meilleure periode;%d;%d;%ld\n", debut, fin, meilleure);
|
||||
ajouter_ligne(rapport, ligne);
|
||||
snprintf(ligne, sizeof(ligne), "paires opposees;%ld\n", nb_paires);
|
||||
ajouter_ligne(rapport, ligne);
|
||||
snprintf(ligne, sizeof(ligne), "facons de rendre %d;%ld\n", MONTANT_MONNAIE, nb_facons);
|
||||
ajouter_ligne(rapport, ligne);
|
||||
for (int c = 0; c < 12; c++) {
|
||||
snprintf(ligne, sizeof(ligne), "categorie;%d;%d\n", c, categories[c]);
|
||||
ajouter_ligne(rapport, ligne);
|
||||
}
|
||||
for (int c = 0; c < NB_CLIENTS; c++) {
|
||||
snprintf(ligne, sizeof(ligne), "client;%d;%ld\n", c, totaux_clients[c]);
|
||||
ajouter_ligne(rapport, ligne);
|
||||
}
|
||||
for (int j = 0; j < NB_JOURS; j++) {
|
||||
snprintf(ligne, sizeof(ligne), "jour;%d;%ld\n", j, totaux_jours[j]);
|
||||
ajouter_ligne(rapport, ligne);
|
||||
}
|
||||
for (int i = 0; i < NB_TRANSACTIONS; i += 10) {
|
||||
snprintf(ligne, sizeof(ligne), "rang;%d;%d;%ld\n", i, t[i].id, t[i].montant);
|
||||
ajouter_ligne(rapport, ligne);
|
||||
}
|
||||
|
||||
FILE *f = fopen("rapport.txt", "w");
|
||||
if (f != NULL) {
|
||||
fputs(rapport, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
printf("Clients distincts : %d\n", nb_clients);
|
||||
printf("Somme des requêtes : %ld\n", somme_requetes);
|
||||
printf("Meilleure période : jours %d à %d (%ld)\n", debut, fin, meilleure);
|
||||
printf("Paires opposées : %ld\n", nb_paires);
|
||||
printf("Façons de rendre %d : %ld\n", MONTANT_MONNAIE, nb_facons);
|
||||
printf("Empreinte : %016lx\n", empreinte(rapport));
|
||||
|
||||
free(rapport);
|
||||
free(t);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
Flat profile:
|
||||
|
||||
Each sample counts as 0.01 seconds.
|
||||
% cumulative self self total
|
||||
time seconds seconds calls ms/call ms/call name
|
||||
28.50 0.88 0.88 1 875.00 875.00 nb_facons_rendre
|
||||
26.38 1.69 0.81 1 810.00 810.00 nb_paires_opposees
|
||||
24.76 2.44 0.76 30000 0.03 0.03 rechercher_par_id
|
||||
7.82 2.69 0.24 6017 0.04 0.04 longueur
|
||||
7.82 2.92 0.24 1 240.00 240.00 meilleure_periode
|
||||
2.61 3.00 0.08 1 80.00 80.00 total_par_client
|
||||
1.30 3.04 0.04 1 40.00 40.00 total_par_jour
|
||||
0.49 3.06 0.01 30000 0.00 0.00 categorie
|
||||
0.33 3.07 0.01 29999 0.00 0.00 fusionner
|
||||
0.00 3.07 0.00 149998 0.00 0.00 alea
|
||||
0.00 3.07 0.00 6017 0.00 0.04 ajouter_ligne
|
||||
0.00 3.07 0.00 1 0.00 0.00 empreinte
|
||||
0.00 3.07 0.00 1 0.00 0.00 generer_transactions
|
||||
0.00 3.07 0.00 1 0.00 0.00 nb_clients_distincts
|
||||
0.00 3.07 0.00 1 0.00 10.00 trier_par_montant
|
||||
|
||||
Call graph
|
||||
|
||||
|
||||
granularity: each sample hit covers 4 byte(s) for 0.33% of 3.07 seconds
|
||||
|
||||
index % time self children called name
|
||||
<spontaneous>
|
||||
[1] 100.0 0.00 3.07 main [1]
|
||||
0.88 0.00 1/1 nb_facons_rendre [2]
|
||||
0.81 0.00 1/1 nb_paires_opposees [3]
|
||||
0.76 0.00 30000/30000 rechercher_par_id [4]
|
||||
0.00 0.24 6017/6017 ajouter_ligne [5]
|
||||
0.24 0.00 1/1 meilleure_periode [7]
|
||||
0.08 0.00 1/1 total_par_client [8]
|
||||
0.04 0.00 1/1 total_par_jour [9]
|
||||
0.01 0.00 30000/30000 categorie [10]
|
||||
0.00 0.01 1/1 trier_par_montant [12]
|
||||
0.00 0.00 1/1 generer_transactions [15]
|
||||
0.00 0.00 1/1 nb_clients_distincts [16]
|
||||
0.00 0.00 1/1 empreinte [14]
|
||||
-----------------------------------------------
|
||||
266723738 nb_facons_rendre [2]
|
||||
0.88 0.00 1/1 main [1]
|
||||
[2] 28.5 0.88 0.00 1+266723738 nb_facons_rendre [2]
|
||||
266723738 nb_facons_rendre [2]
|
||||
-----------------------------------------------
|
||||
0.81 0.00 1/1 main [1]
|
||||
[3] 26.4 0.81 0.00 1 nb_paires_opposees [3]
|
||||
-----------------------------------------------
|
||||
0.76 0.00 30000/30000 main [1]
|
||||
[4] 24.8 0.76 0.00 30000 rechercher_par_id [4]
|
||||
-----------------------------------------------
|
||||
0.00 0.24 6017/6017 main [1]
|
||||
[5] 7.8 0.00 0.24 6017 ajouter_ligne [5]
|
||||
0.24 0.00 6017/6017 longueur [6]
|
||||
-----------------------------------------------
|
||||
0.24 0.00 6017/6017 ajouter_ligne [5]
|
||||
[6] 7.8 0.24 0.00 6017 longueur [6]
|
||||
-----------------------------------------------
|
||||
0.24 0.00 1/1 main [1]
|
||||
[7] 7.8 0.24 0.00 1 meilleure_periode [7]
|
||||
-----------------------------------------------
|
||||
0.08 0.00 1/1 main [1]
|
||||
[8] 2.6 0.08 0.00 1 total_par_client [8]
|
||||
-----------------------------------------------
|
||||
0.04 0.00 1/1 main [1]
|
||||
[9] 1.3 0.04 0.00 1 total_par_jour [9]
|
||||
-----------------------------------------------
|
||||
0.01 0.00 30000/30000 main [1]
|
||||
[10] 0.5 0.01 0.00 30000 categorie [10]
|
||||
-----------------------------------------------
|
||||
0.01 0.00 29999/29999 trier_par_montant [12]
|
||||
[11] 0.3 0.01 0.00 29999 fusionner [11]
|
||||
-----------------------------------------------
|
||||
0.00 0.01 1/1 main [1]
|
||||
[12] 0.3 0.00 0.01 1 trier_par_montant [12]
|
||||
0.01 0.00 29999/29999 fusionner [11]
|
||||
-----------------------------------------------
|
||||
0.00 0.00 149998/149998 generer_transactions [15]
|
||||
[13] 0.0 0.00 0.00 149998 alea [13]
|
||||
-----------------------------------------------
|
||||
0.00 0.00 1/1 main [1]
|
||||
[14] 0.0 0.00 0.00 1 empreinte [14]
|
||||
-----------------------------------------------
|
||||
0.00 0.00 1/1 main [1]
|
||||
[15] 0.0 0.00 0.00 1 generer_transactions [15]
|
||||
0.00 0.00 149998/149998 alea [13]
|
||||
-----------------------------------------------
|
||||
0.00 0.00 1/1 main [1]
|
||||
[16] 0.0 0.00 0.00 1 nb_clients_distincts [16]
|
||||
-----------------------------------------------
|
||||
|
||||
Index by function name
|
||||
|
||||
[5] ajouter_ligne [15] generer_transactions [3] nb_paires_opposees
|
||||
[13] alea [6] longueur [4] rechercher_par_id
|
||||
[10] categorie [7] meilleure_periode [8] total_par_client
|
||||
[14] empreinte [16] nb_clients_distincts [9] total_par_jour
|
||||
[11] fusionner (banque.c) [2] nb_facons_rendre [12] trier_par_montant
|
||||
+6017
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user