def consultByGenre(catalog, lstgenre): delta_time = -1.0 delta_memory = -1.0 tracemalloc.start() start_time = getTime() start_memory = getMemory() for genre in lstgenre: range = model.getGenreRange(catalog, genre) reprod = model.reprodByCharactRange(catalog, 'tempo', (range[0], range[1])) unicartist = model.unicTrackorArtist(catalog, reprod[0], 'artist_id') lstresult = model.selectResults(unicartist[0], 5, False) print('\nFor ' + genre.capitalize(), ' the tempo is between ', range[0], ' and ', range[1], ' BPM\n' + genre.capitalize(), ' reproductions: ', reprod[1], ' with ', unicartist[1], ' different artists\n\n', '----- Some artists for ' + genre.capitalize() + ' -----') for value in lt.iterator(lstresult): print(value) stop_memory = getMemory() stop_time = getTime() tracemalloc.stop() delta_time = stop_time - start_time delta_memory = deltaMemory(start_memory, stop_memory) return (delta_time, delta_memory)
def reprodByCharactRange(catalog, characteristics, range): delta_time = -1.0 delta_memory = -1.0 tracemalloc.start() start_time = getTime() start_memory = getMemory() reprod = model.reprodByCharactRange(catalog, characteristics, range) result = model.unicTrackorArtist(catalog, reprod[0], 'artist_id') stop_memory = getMemory() stop_time = getTime() tracemalloc.stop() delta_time = stop_time - start_time delta_memory = deltaMemory(start_memory, stop_memory) return ((reprod[1], result[1]), (delta_time, delta_memory))
def totalReprodByGenre(catalog, lstgenre): delta_time = -1.0 delta_memory = -1.0 tracemalloc.start() start_time = getTime() start_memory = getMemory() reprod = 0 for genre in lstgenre: range = model.getGenreRange(catalog, genre) reprod += model.reprodByCharactRange(catalog, 'tempo', (range[0], range[1]))[1] stop_memory = getMemory() stop_time = getTime() tracemalloc.stop() delta_time = stop_time - start_time delta_memory = deltaMemory(start_memory, stop_memory) return (reprod, (delta_time, delta_memory))
def songByTwoCharactRange(catalog, characteristics, range1, range2): delta_time = -1.0 delta_memory = -1.0 tracemalloc.start() start_time = getTime() start_memory = getMemory() reprod = model.reprodByCharactRange(catalog, characteristics[0], range1) reprod = model.reprodByCharactRangeLst(reprod[0], characteristics[1], range2) unictrack = model.unicTrackorArtist(catalog, reprod[0], 'track_id') result = model.selectResults(unictrack[0], 5, characteristics) stop_memory = getMemory() stop_time = getTime() tracemalloc.stop() delta_time = stop_time - start_time delta_memory = deltaMemory(start_memory, stop_memory) return ((unictrack[1], result), (delta_time, delta_memory))
def reprodGenreByTime(catalog, characteristics, range1): delta_time = -1.0 delta_memory = -1.0 tracemalloc.start() start_time = getTime() start_memory = getMemory() reprod = model.reprodByCharactRange(catalog, characteristics, range1) reprod = model.reprodGenreByTime(catalog, reprod[0]) unictrack = model.unicTrackorArtist(catalog, reprod[1], 'track_id') model.addHashtagProm(catalog, unictrack[0]) lstreprodsort = model.mergeSortVideos(unictrack[0], lt.size(unictrack[0]), 'hashtag')[0] lstvalues = model.selectResults(lstreprodsort, 10, True) stop_memory = getMemory() stop_time = getTime() tracemalloc.stop() delta_time = stop_time - start_time delta_memory = deltaMemory(start_memory, stop_memory) return (((reprod[0], lstvalues), unictrack[1]), (delta_time, delta_memory))