Bonjour,
Voilà j'étais plutôt intéressé par ce langage. Une sorte de C++ simplifié qui combine performance et productivité dans un seul et même langage.
Du coup j'installe tout ça, je fais un test de perf et que vois-je ? Mon programme en D met 40 secondes là où en C# il n'en met que 15 !
Le code C# :
Le code D :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74 using System; using System.Diagnostics; namespace CSharpPerform { class Program { static void Main(string[] args) { Console.WriteLine("Tape \"Y\" to launch benchmark or any other touch to exit program :"); string s = Console.ReadLine(); while(s == "y" || s == "Y") { Benchmark(); s = Console.ReadLine(); } } static void Benchmark() { Stopwatch time = new Stopwatch(); time.Start(); uint count = 0; student michael = null; while (count < 1000000) { michael = new student("Michael", new DateTime(1998, 5, 1), 12); string state = michael.GetState(); count++; } time.Stop(); Console.WriteLine("Temps d'exécution : " + time.ElapsedMilliseconds.ToString() + "ms"); } class student { private string _name; private DateTime _birthday; private int _evaluation; public string GetState() { return _name + " est né le " + _birthday.ToLongDateString() + " et son évaluation est de " + _evaluation.ToString(); } public student(string name, DateTime birthday, int eval) { _name = name; _birthday = birthday; _evaluation = eval; } public void SetName(string name) { _name = name; } public void SetBirthday(DateTime date) { _birthday = date; } public void SetEvaluation(int eval) { _evaluation = eval; } } } }
Le D n'est donc pas fait pour de l'informatique de gestion ? Où alors (surement) ai-je développé la partie D comme un porc ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 import std.stdio; import std.string; import std.datetime; import std.conv; int main(string[] argv) { writeln("Tape \"Y\" to launch benchmark or any other touch to exit program :"); string s = chomp(readln()); while(s == "y" || s == "Y") { auto bench = benchmark!(Benchmark)(1); writefln("Temps d'exécution : %s ms", bench[0].msecs); s = chomp(readln()); } return 0; } void Benchmark() { uint count = 0; student michael = null; while (count < 1000000) { michael = new student("Michael", Date(1998, 5, 1), 12); dstring state = michael.getState(); count++; } } class student { private dstring _name; private Date _birthday; private int _evaluation; public dstring getState() { return _name ~ " est né le "d ~ to!dstring(_birthday.toSimpleString()) ~ " et son évaluation est de "d ~ to!dstring(_evaluation); } this(dstring name, Date birthday, int eval) { _name = name; _birthday = birthday; _evaluation = eval; } public void SetName(dstring name) { _name = name; } public void SetBirthday(Date birthday) { _birthday = birthday; } public void SetEvaluation(int eval) { _evaluation = eval; } }
Partager