Icon representing a recipe

Recipe: Foldit Benchmark v1.0

created by joshmiller

Profile


Name
Foldit Benchmark v1.0
ID
104201
Shared with
Public
Parent
None
Children
None
Created on
December 09, 2020 at 22:42 PM UTC
Updated on
December 09, 2020 at 22:42 PM UTC
Description

Times and tests every supported Lua function.

Best for


Code


-- Foldit Benchmark Test by joshmiller -- Times and tests every supported Lua function -- v 1.0, 12/6/2020 segmentCount = structure.GetCount() function DoByStride (stride, index, func, useIndex, ...) selection.DeselectAll() local segCnt = structure.GetCount () for ii = index, segCnt, stride do selection.Select(ii) if (useIndex) then func(ii, unpack(arg)) else func(unpack(arg)) end selection.DeselectAll() end end function DoXTimes(X, func, ...) for i = 1, X do func(unpack(arg)) end end function timeFunc(iters, name, func, ...) recipe.SectionStart(name) startTime = os.clock() DoXTimes(iters, func, ...) result = os.clock() - startTime print (name, "took", result, "seconds") recipe.SectionEnd() return result end function doBands() band.Add(1,2,3,4,1,2) DoByStride(5, 1, band.AddBetweenSegments, true, 1) DoByStride(6, 1, band.AddToBandEndpoint, true, 1) band.Delete(1) band.Disable(1) band.Enable(1) band.GetAtomBase(1) band.GetAtomEnd(1) band.GetCount() band.GetGoalLength(1) band.GetLength(1) band.GetResidueBase(1) band.GetResidueEnd(1) band.GetStrength(1) band.IsEnabled(1) band.IsRecipeBand(1) for i = 1, 25 do band.DisableAll() band.EnableAll() band.SetGoalLength(1, 10) band.SetStrength(1, 10) end band.DeleteAll() end function doBehavior() for i = 1, 50 do behavior.GetBackboneHBondImportance() behavior.GetClashImportance() behavior.GetDensityImportance() behavior.GetFiltersDisabled() behavior.GetHidingImportance() behavior.GetPackingImportance() behavior.GetPairwiseImportance() behavior.GetSidechainHBondImportance() setting = behavior.GetSlowFiltersDisabled() setting = behavior.GetFiltersDisabled() behavior.GetWigglePower() behavior.HighPowerAllowed() behavior.SetBackboneHBondImportance(0.9) behavior.SetClashImportance(0.9) behavior.SetDensityImportance(1.1) behavior.SetHidingImportance(1.1) behavior.SetPackingImportance(1.1) behavior.SetPairwiseImportance(1.1) behavior.SetSidechainHBondImportance(1.1) behavior.SetBackboneHBondImportance(0.2) behavior.SetClashImportance(0.4) behavior.SetDensityImportance(1.5) behavior.SetHidingImportance(1.6) behavior.SetPackingImportance(1.2) behavior.SetPairwiseImportance(1.5) behavior.SetSidechainHBondImportance(1.2) behavior.SetSlowFiltersDisabled(setting) behavior.SetFiltersDisabled(setting) behavior.SetWigglePower("a") behavior.SetWigglePower("l") behavior.UseCutBands(true) behavior.UseCutBands(false) end end function doFiltersHelper(filterNames) for i,name in pairs(filterNames) do filter.ConditionSatisfied(name) filter.Disable(name) filter.Enable(name) filter.GetBonus(name) filter.HasBonus(name) filter.IsEnabled(name) end end function doFilters() filter.AreAllEnabled() filter.DisableAll() filter.EnableAll() filter.GetBonusTotal() metric.GetBonusTotal() filter.GetDisabledNames() filter.GetEnabledNames() filterNames = filter.GetNames() metricNames = metric.GetNames() doFiltersHelper(filterNames) doFiltersHelper(metricNames) end function doToolsHelper(i) freeze.Freeze(i, true, true) freeze.IsFrozen(i) freeze.Unfreeze(i, true, true) rotamer.GetCount(i) rotamer.SetRotamer(i, 1) selection.Select(i) selection.SelectRange(i, 1) selection.IsSelected(i) structure.IdealSSSelected() structure.IdealizeSelected() structure.LocalWiggleSelected(1) structure.MutateSidechainsSelected(1) structure.RebuildSelected(1) structure.RemixSelected(1, 3) structure.SetAminoAcidSelected("l") structure.ShakeSidechainsSelected(1) structure.WiggleSelected(1) freeze.FreezeSelected(true, true) freeze.UnfreezeAll() structure.InsertCut(i) structure.CanMutate(i, "l") structure.DeleteCut(i) structure.DeleteResidue(i) structure.GetAminoAcid(i) structure.GetAtomCount(i) structure.GetDistance(i, 1) structure.GetNote(i) structure.GetSecondaryStructure(i) structure.GetSymCount() structure.InsertResidue(i) structure.IsHydrophobic(i) structure.IsLocked(i) structure.IsMutable(i) structure.SetAminoAcid(i, "l") structure.SetNote(i, "Test Note") structure.SetSecondaryStructure(i, "h") structure.SetSecondaryStructureSelected("a") selection.Deselect(i) selection.DeselectAll() end function doTools() structure.GetCount() freeze.FreezeAll() freeze.UnfreezeAll() freeze.GetCount() selection.SelectAll() selection.DeselectAll() selection.GetCount() structure.LocalWiggleAll(3) structure.MutateSidechainsAll(1) structure.ShakeSidechainsAll(3) structure.WiggleAll(3) DoByStride(35, 1, doToolsHelper, true) end function doMisc() contactmap.GetHeat(1, 2) contactmap.IsContact(1, 2) recentbest.Save() creditbest.AreConditionsMet() creditbest.GetEnergyScore() creditbest.GetExplorationMultiplier() creditbest.GetScore() creditbest.GetSegmentEnergyScore(1) creditbest.Restore() current.AreConditionsMet() current.GetEnergyScore() current.GetExplorationMultiplier() current.GetScore() current.GetSegmentEnergyScore(1) subscores = puzzle.GetPuzzleSubscoreNames() for ii = 1, #subscores do current.GetSegmentEnergySubscore(1, subscores[ii]) recentbest.GetSegmentEnergySubscore(1, subscores[ii]) creditbest.GetSegmentEnergySubscore(1, subscores[ii]) end puzzle.GetDescription() puzzle.GetExpirationTime() puzzle.GetName() puzzle.GetPuzzleID() puzzle.GetStructureName() puzzle.StartOver() recentbest.AreConditionsMet() recentbest.GetEnergyScore() recentbest.GetExplorationMultiplier() recentbest.GetScore() recentbest.GetSegmentEnergyScore(1) recentbest.Restore() recipe.CompareNumbers(1, 2.5) recipe.GetRandomSeed() recipe.ReportStatus() save.GetSolutions() save.LoadSecondaryStructure() save.Quicksave(1) save.Quickload(1) save.QuicksaveEmpty(1) save.SaveSecondaryStructure() save.SaveSolution("Benchmark Test") sols = save.GetSolutions() for ii = 1, #sols do if sols[ii].name == "Benchmark Test" then save.LoadSolution(sols[ii]) end end save.LoadSolutionByName("Bechmark Test") scoreboard.GetGroupRank() scoreboard.GetGroupScore() scoreboard.GetRank() scoreboard.GetScore() scoreboard.GetScoreType() ui.AlignGuide() ui.CenterViewport() ui.GetPlatform() ui.GetTrackName() undo.SetUndo(true) user.GetGroupID() user.GetGroupName() user.GetPlayerID() user.GetPlayerName() end -- MAIN local prompt = dialog.CreateDialog("Foldit Benchmark") prompt.Warning = dialog.AddLabel("Warning: This recipe will overwrite your current pose,") prompt.Warning2 = dialog.AddLabel("recent best, and Quicksave 1.") prompt.Warnin3 = dialog.AddLabel("Please save progress before running this recipe.") prompt.Length = dialog.AddSlider("Iterations", 1, 1, 25, 0) prompt.Instructions = dialog.AddLabel("Test Sections:") prompt.DoBands = dialog.AddCheckbox("Bands", true) prompt.DoBehavior = dialog.AddCheckbox("Behavior", true) prompt.DoFilters = dialog.AddCheckbox("Filters", true) prompt.DoTools = dialog.AddCheckbox("Tools", true) prompt.DoMisc = dialog.AddCheckbox("Misc", true) prompt.OK = dialog.AddButton("OK", 1) prompt.Cancel = dialog.AddButton("Cancel", 0) if (dialog.Show(prompt) > 0) then if prompt.DoBands.value then bandTime = timeFunc(prompt.Length.value, "Bands", doBands) end if prompt.DoBehavior.value then behaviorTime = timeFunc(prompt.Length.value, "Behavior", doBehavior) end if prompt.DoFilters.value then filterTime = timeFunc(prompt.Length.value, "Filters", doFilters) end if prompt.DoTools.value then toolTime = timeFunc(prompt.Length.value, "Tools", doTools) end if prompt.DoMisc.value then miscTime = timeFunc(prompt.Length.value, "Misc", doMisc) end else print("Benchmark cancelled.") end string_results = "" local tell = dialog.CreateDialog("Benchmark Results") if prompt.DoBands.value then results = "Bands: " .. bandTime .. " seconds" string_results = string_results .. results .. "\n" tell.Bands = dialog.AddLabel(results) end if prompt.DoBehavior.value then results = "Behavior: " .. behaviorTime .. " seconds" string_results = string_results .. results .. "\n" tell.Behavior = dialog.AddLabel(results) end if prompt.DoFilters.value then results = "Filters: " .. filterTime .. " seconds" string_results = string_results .. results .. "\n" tell.Filters = dialog.AddLabel(results) end if prompt.DoTools.value then results = "Tools: " .. toolTime .. " seconds" string_results = string_results .. results .. "\n" tell.Tools = dialog.AddLabel(results) end if prompt.DoMisc.value then results = "Misc: " .. miscTime .. " seconds" string_results = string_results .. results .. "\n" tell.Misc = dialog.AddLabel(results) end tell.Results = dialog.AddTextbox("Copyable: ", string_results) tell.OK = dialog.AddButton("Done", 1) dialog.Show(tell)

Comments