Linux iad1-shared-b7-18 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
Apache
: 67.205.6.31 | : 216.73.216.13
Cant Read [ /etc/named.conf ]
8.2.29
fernandoquevedo
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
README
+ Create Folder
+ Create File
/
usr /
share /
doc /
ruby-concurrent /
examples /
[ HOME SHELL ]
Name
Size
Permission
Action
a-tour-of-go-channels
[ DIR ]
drwxr-xr-x
go-by-example-channels
[ DIR ]
drwxr-xr-x
actor_stress_test.rb
3.23
KB
-rwxr-xr-x
atomic_example.rb
392
B
-rwxr-xr-x
benchmark_async.rb
6.81
KB
-rwxr-xr-x
benchmark_atomic.rb
2.53
KB
-rwxr-xr-x
benchmark_atomic_1.rb
2.52
KB
-rwxr-xr-x
benchmark_atomic_boolean.rb
984
B
-rwxr-xr-x
benchmark_atomic_fixnum.rb
964
B
-rwxr-xr-x
benchmark_map.rb
581
B
-rwxr-xr-x
benchmark_new_futures.rb
2.16
KB
-rwxr-xr-x
benchmark_read_write_lock.rb
4.27
KB
-rwxr-xr-x
benchmark_structs.rb
4.66
KB
-rwxr-xr-x
format.rb
1.86
KB
-rw-r--r--
graph_atomic_bench.rb
1.73
KB
-rwxr-xr-x
init.rb
104
B
-rw-r--r--
stress_ruby_thread_pool.rb
791
B
-rwxr-xr-x
thread_local_memory_usage.rb
1.61
KB
-rwxr-xr-x
thread_local_var_bench.rb
606
B
-rwxr-xr-x
who.rb
711
B
-rwxr-xr-x
Delete
Unzip
Zip
${this.title}
Close
Code Editor : benchmark_atomic.rb
#!/usr/bin/env ruby #$: << File.expand_path('../../lib', __FILE__) require 'benchmark' require 'rbconfig' require 'thread' require 'concurrent/atomics' if RUBY_PLATFORM != 'java' && ! defined? Concurrent::CAtomicReference warn "[WARN] C extensions not loaded!" end Thread.abort_on_exception = true $go = false # for synchronizing parallel threads # number of updates on the value N = ARGV[1] ? ARGV[1].to_i : 100_000 # number of threads for parallel test M = ARGV[0] ? ARGV[0].to_i : 10 # list of platform-specific implementations ATOMICS = [ 'MutexAtomicReference', 'CAtomicReference', 'JavaAtomicReference', 'RbxAtomicReference', ] puts "Testing with #{RbConfig::CONFIG['ruby_install_name']} #{RUBY_VERSION}" puts puts '*** Sequential updates ***' Benchmark.bm(10) do |x| value = 0 x.report 'no lock' do N.times do value += 1 end end @lock = Mutex.new x.report 'mutex' do value = 0 N.times do @lock.synchronize do value += 1 end end end ATOMICS.each do |clazz| if Concurrent.const_defined? clazz @atom = Concurrent.const_get(clazz).new(0) x.report clazz do N.times do @atom.update{|x| x += 1} end end end end end def para_setup(num_threads, count, &block) if num_threads % 2 > 0 raise ArgumentError, 'num_threads must be a multiple of two' end raise ArgumentError, 'need block' unless block_given? # Keep those threads together tg = ThreadGroup.new num_threads.times do |i| diff = (i % 2 == 0) ? 1 : -1 t = Thread.new do nil until $go count.times do yield diff end end tg.add(t) end # Make sure all threads are started while tg.list.find{|t| t.status != 'run'} Thread.pass end # For good measure GC.start tg end def para_run(tg) $go = true tg.list.each{|t| t.join} $go = false end puts puts '*** Parallel updates ***' Benchmark.bm(10) do |bm| # This is not secure value = 0 tg = para_setup(M, N/M) do |diff| value += diff end bm.report('no lock'){ para_run(tg) } value = 0 @lock = Mutex.new tg = para_setup(M, N/M) do |diff| @lock.synchronize do value += diff end end bm.report('mutex'){ para_run(tg) } raise unless value == 0 ATOMICS.each do |clazz| if Concurrent.const_defined? clazz @atom = Concurrent.const_get(clazz).new(0) tg = para_setup(M, N/M) do |diff| @atom.update{|x| x + diff} end bm.report(clazz){ para_run(tg) } raise unless @atom.value == 0 end end end
Close