Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
P
Projet_Q4_Groupe_O4
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de conteneur
Registre de modèles
Opération
Environnements
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Conditions générales et politique de confidentialité
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Louis Malevez
Projet_Q4_Groupe_O4
Validations
a237f8b2
Valider
a237f8b2
rédigé
5 years ago
par
Jonathan Twite
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Update prime_divs.c (commented for better readability)
parent
d448bb62
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
1
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
prime_divs.c
+11
-22
11 ajouts, 22 suppressions
prime_divs.c
avec
11 ajouts
et
22 suppressions
prime_divs.c
+
11
−
22
Voir le fichier @
a237f8b2
...
...
@@ -11,50 +11,39 @@
#include
<string.h>
#include
"fileFeatures.h"
// int max value: 2 147 483 647
// long max value: 9223372 036 854 775 807
// char *filepath = "/home/jtwite/Desktop/test";
// Remplacez-le contenu par le chemin relatif du fichier que vous souhaitez tester.
int
main
(
int
argc
,
char
*
argv
[])
{
struct
timeval
stop
,
start
;
gettimeofday
(
&
start
,
NULL
);
printf
(
"argv[1]: %s
\n
"
,
argv
[
1
]);
printf
(
"argv[2]: %s
\n
"
,
argv
[
2
]);
printf
(
"argv[1]: %s
\n
"
,
argv
[
1
]);
// argv[1] = input file path
printf
(
"argv[2]: %s
\n
"
,
argv
[
2
]);
// argv[2] = output file path
//open the file
//open the file
Input
int
fileInput
=
open
(
argv
[
1
],
O_RDONLY
);
if
(
fileInput
<=
0
)
exit
(
1
);
// get the fileInput size
// get the fileInput size
, map it in the virtual &dress space and close fileInput directory
struct
stat
sb
;
fstat
(
fileInput
,
&
sb
);
char
*
file_in_memory
=
mmap
(
NULL
,
sb
.
st_size
,
PROT_READ
,
MAP_PRIVATE
,
fileInput
,
0
);
close
(
fileInput
);
// Create a new file struct in which the output is writen
FILE
*
fileOutput
=
fopen
(
argv
[
2
],
"w"
);
FILE
*
fileOutput
=
fopen
(
argv
[
2
],
"w"
);
// Create the file output
if
(
fileOutput
==
NULL
)
exit
(
-
2
);
//go through the mapped file to get numbers and write them in fileOutput
//go through the mapped file, read numbers and write them in fileOutput
factorize
(
file_in_memory
,
fileOutput
);
//
close everything
//
unmap fileInput and close fileOutput
munmap
(
file_in_memory
,
sb
.
st_size
);
fclose
(
fileOutput
);
// print out the computation performance
gettimeofday
(
&
stop
,
NULL
);
printf
(
"
took %lu µs
\n
"
,
(
stop
.
tv_sec
-
start
.
tv_sec
)
*
1000000
+
stop
.
tv_usec
-
start
.
tv_usec
);
printf
(
"
%s factorized into %s.
\n
took %lu µs
\n
"
,
argv
[
1
],
argv
[
2
]
,
(
stop
.
tv_sec
-
start
.
tv_sec
)
*
1000000
+
stop
.
tv_usec
-
start
.
tv_usec
);
return
0
;
}
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter