⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Ruby master
All Projects
Ruby
»
Ruby master
Overview
Activity
Roadmap
Issues
Repository
Like
Download (955 Bytes)
Bug #10009
» teste_thread_schedule.rb
ariveira (Alexandre Riveira)
, 07/08/2014 09:56 AM
#puts "definindo taskset -c -p 1 #{Process.pid}"
#`taskset -c -p 2 #{Process.pid}`
inicio_geral
=
Time
.
now
t1
=
Thread
.
new
do
Thread
.
current
[
:target
]
=
0
while
true
Thread
.
current
[
:target
]
+=
1
end
end
10
.
downto
(
0
)
do
|
i
|
inicio
=
Time
.
now
Kernel
.
sleep
(
1
)
puts
"faltando
#{
i
}
segundos (
#{
Time
.
now
-
inicio
}
)"
end
puts
"zerando thread com contagem em
#{
t1
[
:target
]
}
"
t1
[
:target
]
=
0
t2
=
Thread
.
new
do
Thread
.
current
[
:target
]
=
0
while
true
Thread
.
current
[
:target
]
+=
1
end
end
t3
=
Thread
.
new
do
Thread
.
current
[
:target
]
=
0
while
true
Thread
.
current
[
:target
]
+=
1
end
end
10
.
times
do
puts
"primeira
#{
t1
[
:target
]
}
"
puts
"segunda
#{
t2
[
:target
]
}
"
puts
"terceira
#{
t3
[
:target
]
}
"
puts
"
\n\n
"
sleep
(
1
)
end
total
=
t1
[
:target
].
to_i
+
t2
[
:target
].
to_i
+
t3
[
:target
].
to_i
puts
"total
#{
total
}
"
puts
"media
#{
total
/
(
Time
.
now
-
inicio_geral
).
to_i
}
"
puts
"
\n\n
"
puts
"time
#{
Time
.
now
-
inicio_geral
}
"
« Previous
1
2
3
4
5
…
8
Next »
(3-3/8)
Loading...