Het Wat heb jij vandaag geprogrammeerd? topic

Gestart doorAarclay4.538 reacties23.755 weergaven

4.539 berichten · pagina 303 van 303

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Kitnkiller schreef:
Eerdere citaten tonen
Bugged schreef:
Eerdere citaten tonen
Kitnkiller schreef:
Eerdere citaten tonen
Dylan schreef:
Mijn eerste programma met C# (CPU Stress test)
Afbeelding

Wat doet launchStress()?
De stresstest starten?
...
Ja, maar op welke manier?

private void launchStress() {
    while(true) {
        launchStress();
    }
}

Spoiler tonen
Codeblok (voorbeeld.php):
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Diagnostics;

namespace CPUStressTest
{
class Program
{
static void Main(string[] args)
{
AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);
Console.Title = "CPU Stress Test by DazDylz";
Console.BackgroundColor = ConsoleColor.DarkRed;
Console.ForegroundColor = ConsoleColor.Yellow;
string[] texts = new string[6] {
"Welcome to my CPU Stress Tester!",
"This is the first time I made a program in C#",
"so dont expect something good smile",
"nr",
"Press enter to quit the program (may take a second)",
"nrnr"
};
initTest(texts);
Console.BackgroundColor = ConsoleColor.Green;
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("Press any key to start the test");

Thread TitleBar = new Thread(new ThreadStart(titleBar));
Console.Read();
Console.ResetColor();
Console.Clear();
TitleBar.Start();
launchStress();

while (true)
{
if (Console.ReadKey().Key.ToString().ToUpper() == "ENTER")
{
OnProcessExit(); // OVERLOAD!!!
}
}

}

static void OnProcessExit(object sender, EventArgs e)
{
Console.WriteLine("Bye!");
Environment.Exit(0);
}

static void OnProcessExit()
{
Console.WriteLine("Bye!");
Environment.Exit(0);
}

static void initTest(string[] texts)
{
foreach(string text in texts) {
Console.WriteLine("{0}", text.ToString());
}
}

static void titleBar()
{
PerformanceCounter cpuUsage;
cpuUsage = new PerformanceCounter();
cpuUsage.CategoryName = "Processor";
cpuUsage.CounterName = "% Processor Time";
cpuUsage.InstanceName = "_Total";

while (true)
{
Console.Title = "CPU Usage: " + Math.Round(cpuUsage.NextValue(), 1) + "%";
Thread.Sleep(500);
}
}

static int getRandomInt()
{
return new Random().Next(1, 51023);
}

static void stress()
{
while (true)
{
Console.Write(getRandomInt() * getRandomInt());
}
}

static void launchStress()
{
for (int core = 0; core < Environment.ProcessorCount; core++)
{
Thread threadStress = new Thread(new ThreadStart(stress));
threadStress.Start();
}
}
}
}

toevoeging op 27 mei 2015, 13:05:43:
Afbeelding

toevoeging op 27 mei 2015, 13:07:13:
Afbeelding
0
Berichten
518
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dylan schreef:
Eerdere citaten tonen
Kitnkiller schreef:
Eerdere citaten tonen
Bugged schreef:
Eerdere citaten tonen
Kitnkiller schreef:
Eerdere citaten tonen
Dylan schreef:
Mijn eerste programma met C# (CPU Stress test)
Afbeelding

Wat doet launchStress()?
De stresstest starten?
...
Ja, maar op welke manier?

private void launchStress() {
    while(true) {
        launchStress();
    }
}

Codeblok (voorbeeld.php):
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Diagnostics;

namespace CPUStressTest
{
class Program
{
static void Main(string[] args)
{
AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);
Console.Title = "CPU Stress Test by DazDylz";
Console.BackgroundColor = ConsoleColor.DarkRed;
Console.ForegroundColor = ConsoleColor.Yellow;
string[] texts = new string[6] {
"Welcome to my CPU Stress Tester!",
"This is the first time I made a program in C#",
"so dont expect something good smile",
"nr",
"Press enter to quit the program (may take a second)",
"nrnr"
};
initTest(texts);
Console.BackgroundColor = ConsoleColor.Green;
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("Press any key to start the test");

Thread TitleBar = new Thread(new ThreadStart(titleBar));
Console.Read();
Console.ResetColor();
Console.Clear();
TitleBar.Start();
launchStress();

while (true)
{
if (Console.ReadKey().Key.ToString().ToUpper() == "ENTER")
{
OnProcessExit(); // OVERLOAD!!!
}
}

}

static void OnProcessExit(object sender, EventArgs e)
{
Console.WriteLine("Bye!");
Environment.Exit(0);
}

static void OnProcessExit()
{
Console.WriteLine("Bye!");
Environment.Exit(0);
}

static void initTest(string[] texts)
{
foreach(string text in texts) {
Console.WriteLine("{0}", text.ToString());
}
}

static void titleBar()
{
PerformanceCounter cpuUsage;
cpuUsage = new PerformanceCounter();
cpuUsage.CategoryName = "Processor";
cpuUsage.CounterName = "% Processor Time";
cpuUsage.InstanceName = "_Total";

while (true)
{
Console.Title = "CPU Usage: " + Math.Round(cpuUsage.NextValue(), 1) + "%";
Thread.Sleep(500);
}
}

static int getRandomInt()
{
return new Random().Next(1, 51023);
}

static void stress()
{
while (true)
{
Console.Write(getRandomInt() * getRandomInt());
}
}

static void launchStress()
{
for (int core = 0; core < Environment.ProcessorCount; core++)
{
Thread threadStress = new Thread(new ThreadStart(stress));
threadStress.Start();
}
}
}
}

toevoeging op 27 mei 2015, 13:05:43:
Afbeelding

toevoeging op 27 mei 2015, 13:07:13:
Afbeelding

Werkt dit ook echt? Ik zou denken dat die Console.Write gewoon traag is en dus niet veel CPU verbruikt.
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
kuch.
Spoiler tonen
smile
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Kitnkiller schreef:
Eerdere citaten tonen
Dylan schreef:
Eerdere citaten tonen
Kitnkiller schreef:
Eerdere citaten tonen
Bugged schreef:
Eerdere citaten tonen
Kitnkiller schreef:
Eerdere citaten tonen
Dylan schreef:
Mijn eerste programma met C# (CPU Stress test)
Afbeelding

Wat doet launchStress()?
De stresstest starten?
...
Ja, maar op welke manier?

private void launchStress() {
    while(true) {
        launchStress();
    }
}

Codeblok (voorbeeld.php):
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Diagnostics;

namespace CPUStressTest
{
class Program
{
static void Main(string[] args)
{
AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);
Console.Title = "CPU Stress Test by DazDylz";
Console.BackgroundColor = ConsoleColor.DarkRed;
Console.ForegroundColor = ConsoleColor.Yellow;
string[] texts = new string[6] {
"Welcome to my CPU Stress Tester!",
"This is the first time I made a program in C#",
"so dont expect something good smile",
"nr",
"Press enter to quit the program (may take a second)",
"nrnr"
};
initTest(texts);
Console.BackgroundColor = ConsoleColor.Green;
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("Press any key to start the test");

Thread TitleBar = new Thread(new ThreadStart(titleBar));
Console.Read();
Console.ResetColor();
Console.Clear();
TitleBar.Start();
launchStress();

while (true)
{
if (Console.ReadKey().Key.ToString().ToUpper() == "ENTER")
{
OnProcessExit(); // OVERLOAD!!!
}
}

}

static void OnProcessExit(object sender, EventArgs e)
{
Console.WriteLine("Bye!");
Environment.Exit(0);
}

static void OnProcessExit()
{
Console.WriteLine("Bye!");
Environment.Exit(0);
}

static void initTest(string[] texts)
{
foreach(string text in texts) {
Console.WriteLine("{0}", text.ToString());
}
}

static void titleBar()
{
PerformanceCounter cpuUsage;
cpuUsage = new PerformanceCounter();
cpuUsage.CategoryName = "Processor";
cpuUsage.CounterName = "% Processor Time";
cpuUsage.InstanceName = "_Total";

while (true)
{
Console.Title = "CPU Usage: " + Math.Round(cpuUsage.NextValue(), 1) + "%";
Thread.Sleep(500);
}
}

static int getRandomInt()
{
return new Random().Next(1, 51023);
}

static void stress()
{
while (true)
{
Console.Write(getRandomInt() * getRandomInt());
}
}

static void launchStress()
{
for (int core = 0; core < Environment.ProcessorCount; core++)
{
Thread threadStress = new Thread(new ThreadStart(stress));
threadStress.Start();
}
}
}
}
toevoeging op 27 mei 2015, 13:05:43:
Afbeelding

toevoeging op 27 mei 2015, 13:07:13:
Afbeelding

Werkt dit ook echt? Ik zou denken dat die Console.Write gewoon traag is en dus niet veel CPU verbruikt.

Ja, while(true) gaat gewoon zo hard de cpu kan
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
semicolons uit de Passambler gehaald, was een zeer simpele fix om te doen.

er is ook nieuwe syntax voor [c]using[/c], voorheen deed je zoiets

hoi = using(std);
using("math");

hoi.ucase("hoi");
math.ceil(5.5);


Nu dit:

import std as hoi
import math

hoi.ucase("hoi")
math.ceil(5.5)

biggrin
0
Berichten
518
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Raoul schreef:
semicolons uit de Passambler gehaald, was een zeer simpele fix om te doen.

er is ook nieuwe syntax voor [c]using[/c], voorheen deed je zoiets

hoi = using(std);
using("math");

hoi.ucase("hoi");
math.ceil(5.5);
Nu dit:

import std as hoi
import math

hoi.ucase("hoi")
math.ceil(5.5)

biggrin
Net Python redface
Waarom tussen aanhalingstekens btw?
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
het is een expression, omdat je ook bv. bestanden via een variable moet kunnen inladen

x = std
import x


Misschien moet [c]as[/c] ook met expressies werken, geen idee...
0
Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nielsba schreef:
Eerdere citaten tonen
Shahiem schreef:
Klaar met mijn webshop plugin voor Octobercms. Naja voorlopig
Staat die al online tussen de plugins van Octobercms? Ben namelijk opzoek naar een shop systeem voor Octobercms aangezien de shop die nu tussen de plugins staat op dit moment alleen Stripe heeft ingebouwd voor payments. Stripe heeft geen iDeal dacht ik.
Klopt Stripe heeft geen iDeal. Mijn plugin hoeft nog alleen geaccepteerd te worden. Ik moet je wel van te voren vertellen dat het 35 dollar kost. Mijn plugin heeft by the way wel iDeal (Via mollie)
0
Berichten
1.296
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Shahiem schreef:
Eerdere citaten tonen
Nielsba schreef:
Eerdere citaten tonen
Shahiem schreef:
Klaar met mijn webshop plugin voor Octobercms. Naja voorlopig
Staat die al online tussen de plugins van Octobercms? Ben namelijk opzoek naar een shop systeem voor Octobercms aangezien de shop die nu tussen de plugins staat op dit moment alleen Stripe heeft ingebouwd voor payments. Stripe heeft geen iDeal dacht ik.
Klopt Stripe heeft geen iDeal. Mijn plugin hoeft nog alleen geaccepteerd te worden. Ik moet je wel van te voren vertellen dat het 35 dollar kost. Mijn plugin heeft by the way wel iDeal (Via mollie)
Nice ik ben benieuwd als die goedgekeurd is want 35 dollar heb ik er wel voor over.
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren