Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
2
20250331
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
20250331
Commits
b2b378f6
Commit
b2b378f6
authored
Mar 31, 2025
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mierzenie czasu BigDecimal i poprawki
parent
70982f41
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
106 additions
and
2 deletions
+106
-2
SlowoVar.java
src/main/java/gotowe/p02_zmienne/SlowoVar.java
+2
-0
IleDniMaMiesiac5.java
...java/gotowe/p03_instrukcje/c_switch/IleDniMaMiesiac5.java
+1
-0
Imporcik1.java
src/main/java/gotowe/p06_funkcje/importowanie/Imporcik1.java
+1
-1
Imporcik2.java
src/main/java/gotowe/p06_funkcje/importowanie/Imporcik2.java
+1
-1
Double_vs_BigDecimal.java
src/main/java/wydajnosc/Double_vs_BigDecimal.java
+101
-0
No files found.
src/main/java/gotowe/p02_zmienne/SlowoVar.java
View file @
b2b378f6
...
...
@@ -19,6 +19,8 @@ public class SlowoVar {
// y = "Ala ma kota"; // źle
// System.out.println(y);
// var n = null;
// Konstrukcja dostępna tylka dla zmiennych lokalnych, gdy początkową wartość wpisuje się od razu w miejscu deklaracji.
// var z;
...
...
src/main/java/gotowe/p03_instrukcje/c_switch/IleDniMaMiesiac5.java
View file @
b2b378f6
...
...
@@ -13,6 +13,7 @@ public class IleDniMaMiesiac5 {
// to po prostu piszemy go za -> strzałką
case
"styczeń"
,
"marzec"
,
"maj"
,
"lipiec"
,
"sierpień"
,
"październik"
,
"grudzień"
->
31
;
case
"kwiecień"
,
"czerwiec"
,
"wrzesień"
,
"listopad"
->
30
;
// ale jeśli w danym case jest więkcej kroków do wykonania,
// to wynik switcha zwracamy za pomocą słowa yield
case
"luty"
->
{
...
...
src/main/java/gotowe/p06_funkcje/importowanie/Imporcik1.java
View file @
b2b378f6
...
...
@@ -13,7 +13,7 @@ public class Imporcik1 {
System
.
out
.
println
(
list
);
// do własnej listy z bieżącego pakietu muszę odwołać się nazwą kwalifikowaną
p09_importowanie
.
List
<
String
>
patrykList
=
p09_importowanie
.
List
.
of
(
"Patryk"
,
"Tomek"
,
"Wiktor"
);
List
<
String
>
patrykList
=
List
.
of
(
"Patryk"
,
"Tomek"
,
"Wiktor"
);
System
.
out
.
println
(
patrykList
);
// do prawdziwej listy też zawsze mogę się nazwą kwalifikowaną
...
...
src/main/java/gotowe/p06_funkcje/importowanie/Imporcik2.java
View file @
b2b378f6
...
...
@@ -12,7 +12,7 @@ public class Imporcik2 {
System
.
out
.
println
(
list
);
// mogę też odwołać się nazwą kwalifikowaną
p09_importowanie
.
List
<
String
>
patrykList
=
p09_
importowanie
.
List
.
of
(
"Patryk"
,
"Tomek"
,
"Wiktor"
);
gotowe
.
p06_funkcje
.
importowanie
.
List
<
String
>
patrykList
=
gotowe
.
p06_funkcje
.
importowanie
.
List
.
of
(
"Patryk"
,
"Tomek"
,
"Wiktor"
);
System
.
out
.
println
(
patrykList
);
// do prawdziwej listy muszę się nazwą kwalifikowaną
...
...
src/main/java/wydajnosc/Double_vs_BigDecimal.java
0 → 100644
View file @
b2b378f6
package
wydajnosc
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
Double_vs_BigDecimal
{
static
double
[]
wygeneruj1
(
int
n
)
{
double
[]
t
=
new
double
[
n
];
double
x
=
0.01
;
double
krok
=
0.02
;
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
t
[
i
]
=
x
;
x
+=
krok
;
}
return
t
;
}
static
double
suma1
(
double
[]
t
)
{
double
suma
=
0
;
for
(
double
x
:
t
)
{
suma
+=
x
;
}
return
suma
;
}
static
List
<
Double
>
wygeneruj2
(
int
n
)
{
List
<
Double
>
t
=
new
ArrayList
<>(
n
);
double
x
=
0.01
;
double
krok
=
0.02
;
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
t
.
add
(
x
);
x
+=
krok
;
}
return
t
;
}
static
Double
suma2
(
List
<
Double
>
t
)
{
Double
suma
=
0.0
;
for
(
var
x
:
t
)
{
suma
+=
x
;
}
return
suma
;
}
static
List
<
BigDecimal
>
wygeneruj3
(
int
n
)
{
List
<
BigDecimal
>
t
=
new
ArrayList
<>(
n
);
BigDecimal
x
=
new
BigDecimal
(
"0.01"
);
BigDecimal
krok
=
new
BigDecimal
(
"0.02"
);
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
t
.
add
(
x
);
x
=
x
.
add
(
krok
);
}
return
t
;
}
static
BigDecimal
suma3
(
List
<
BigDecimal
>
t
)
{
BigDecimal
suma
=
BigDecimal
.
ZERO
;
for
(
var
x
:
t
)
{
suma
=
suma
.
add
(
x
);
}
return
suma
;
}
public
static
void
main
(
String
[]
args
)
{
int
n
=
100_000_000
;
long
p
,
s
,
k
;
p
=
System
.
nanoTime
();
var
t
=
wygeneruj1
(
n
);
s
=
System
.
nanoTime
();
var
suma1
=
suma1
(
t
);
k
=
System
.
nanoTime
();
System
.
out
.
printf
(
"wynik: %s\n"
,
suma1
);
System
.
out
.
printf
(
"wynik: %.20f\n"
,
suma1
);
System
.
out
.
printf
(
"czas generowania %.3f\n"
,
(
s
-
p
)
*
1
.
e
-
9
);
System
.
out
.
printf
(
"czas sumowania %.3f\n"
,
(
k
-
s
)
*
1
.
e
-
9
);
p
=
System
.
nanoTime
();
var
ld
=
wygeneruj2
(
n
);
s
=
System
.
nanoTime
();
var
suma2
=
suma2
(
ld
);
k
=
System
.
nanoTime
();
System
.
out
.
printf
(
"wynik: %s\n"
,
suma2
);
System
.
out
.
printf
(
"wynik: %.20f\n"
,
suma2
);
System
.
out
.
printf
(
"czas generowania %.3f\n"
,
(
s
-
p
)
*
1
.
e
-
9
);
System
.
out
.
printf
(
"czas sumowania %.3f\n"
,
(
k
-
s
)
*
1
.
e
-
9
);
p
=
System
.
nanoTime
();
var
ldec
=
wygeneruj3
(
n
);
s
=
System
.
nanoTime
();
var
suma3
=
suma3
(
ldec
);
k
=
System
.
nanoTime
();
System
.
out
.
printf
(
"wynik: %s\n"
,
suma3
);
System
.
out
.
printf
(
"wynik: %.20f\n"
,
suma3
);
System
.
out
.
printf
(
"czas generowania %.3f\n"
,
(
s
-
p
)
*
1
.
e
-
9
);
System
.
out
.
printf
(
"czas sumowania %.3f\n"
,
(
k
-
s
)
*
1
.
e
-
9
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment