Exemplo n.º 1
0
import mod

#sum all arguments
print(mod.met(1, 2))
print(mod.met(1, 2, 5))
print(mod.met(1, 2, 5, [1, 2, 3]))
Exemplo n.º 2
0
import sys
sys.path.append('build/lib.linux-x86_64-3.7')

import mod
from random import randint
import time

def Sortowanie_babelkowe(tab, n):
	for i in range(n):
		for j in range(n-1):
			if tab[j] > tab[j + 1]:
				tab[j],tab[j + 1] = tab[j + 1],tab[j]

rozmiary = [10, 10**2, 10**3, 10**4]
tab1_czasy = []
tab2_czasy = []
for rozm in rozmiary:
	tab1 = [randint(0,rozm) for _ in range(rozm)]
	tab2 = [elem for elem in tab1]
	t1_start = time.time()
	Sortowanie_babelkowe(tab1,rozm)
	t1_finish = time.time()
	tab1_czasy.append(t1_finish-t1_start)
	t2_start = time.time()
	mod.met(tab1)
	t2_finish = time.time()
	tab2_czasy.append(t2_finish-t2_start)
	
print("czasy PY: ", tab1_czasy)
print("czasy C: ", tab2_czasy)
Exemplo n.º 3
0
def PythonMod(N):
    start_time = time.time()
    punkty = []
    trafiony = 0
    wszystkie = N*10
    for _ in range(0,N):
        x = r.uniform(0, 1)
        y = r.uniform(0, 1)
        punkty.append((x,y))
    
    kwadrat = [0.1 , 0.1]

    for _ in range(0,10):
        for punkt in punkty:
            if (punkt[0] <= kwadrat[0]):
                if (punkt[1] <= kwadrat[1]):
                    trafiony+=1
        kwadrat[0] += 0.1
        kwadrat[1] += 0.1
     
    print('Execution time: ', (time.time() - start_time))
    
    return trafiony / wszystkie
N=100000
print("Python dla N=", N, 'punktow')
procent = PythonMod(N) * 100
print('trafione punkty: ',procent,'%')

print("C dla N=", N, 'punktow')
procent = mod.met(N) * 100
print('trafione punkty: ',procent,'%')
Exemplo n.º 4
0
sys.path.append(
    "/home/grzegorz/PycharmProjects/Laboratoria/Lab13/build/lib.linux-x86_64-3.7"
)
import mod
import random
from time import time


def sortpy(tab):
    for _ in range(len(tab)):
        for j in range(len(tab) - 1):
            if tab[j] > tab[j + 1]:
                tab[j], tab[j + 1] = tab[j + 1], tab[j]


print(mod.met(1, 2, 3))

tab1 = [random.randint(10, 100) for _ in range(100)]
tab2 = tab1[:]
start = time()
mod.mysort(tab1)
print(time() - start)

start = time()
sortpy(tab2)
print(time() - start)
print(mod.mysrd(tab2))
print(mod.mymed(tab2))
tab = {random.randint(10, 100): random.randint(10, 100) for _ in range(10)}

print(tab)
Exemplo n.º 5
0
import sys
sys.path.append('build/lib.linux-x86_64-3.7')

import mod

print(mod.met(1, 2))  #3
print(mod.met(1, 2, 5))  #8
print(mod.met(1, 2, 5, [2, 3, 4]))  #17
Exemplo n.º 6
0
from sys import path
path.append('build/lib.linux-x86_64-3.5/')

import mod
print(mod.met(1, 2, 4))

import time
from random import randint
size1 = 10
size2 = 10000
t1 = [randint(1, 10) for _ in range(size1)]
t2 = t1[:]


def bub(t1):
    t_start = time.time()
    for i in range(size1):
        for j in range(size1 - 1):
            if t1[j] > t1[j + 1]:
                t1[j], t1[j + 1] = t1[j + 1], t1[j]
    t_end = time.time()
    return t_end - t_start


tc1 = time.time()
mod.bubble(t1)
tc2 = time.time()
print('C: ', tc2 - tc1)
print('Python: ', bub(t2))
Exemplo n.º 7
0
import mod
import random

print('--Zad1--')

print(mod.met(1, 2))
print(mod.met(1, 2, 5))
print(mod.met(1, 2, 5, [2, 3, 4]))

print('--Zad3--')

int_dict = {}
range_max = 50
for i in range(range_max):
    int_dict[random.randint(10, 100)] = random.randint(10, 100)
print(int_dict)
print(mod.met3(int_dict))